【问题标题】:After upgrading to google play services 8.4.0 my app crashes on startup升级到 google play services 8.4.0 后,我的应用程序在启动时崩溃
【发布时间】:2016-04-01 10:21:09
【问题描述】:

我之前一直在使用 google play services 8.3.0 没有任何问题。我正在寻找升级到 google play services 8.4.0。我正在使用以下播放库:

compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'

当我启动应用程序时,它会崩溃,并显示以下日志。

12-27 03:01:33.915 20567-20567/com.ryanc.android.stage.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ryanc.android.stage.debug, PID: 20567
    java.lang.NoSuchMethodError: No static method zzz(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzx; or its super classes (declaration of 'com.google.android.gms.common.internal.zzx' appears in /data/app/com.ryanc.android.stage.debug-1/base.apk:classes17.dex)
    at com.google.android.gms.measurement.internal.zzw.zzaT(Unknown Source)
    at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1696)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
    at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
    at android.app.ActivityThread.access$1500(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

编辑:不确定它会有所帮助,但在@gerardnimo 请求这里是完整的 build.gradle 文件。另外值得注意的是,我尝试了一个干净的构建,并从我的计算机上删除并重新安装了 play services sdk。

apply plugin: 'com.android.application'
apply plugin: 'checkstyle'

def SDK = "$MIN_SDK_VERSION"
def V_CODE = "$VERSION_CODE"

buildscript {
    repositories {
        mavenCentral()
    }
}

repositories {
    mavenCentral()
    jcenter()
    maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' }
    maven { url "http://kahuna.github.io/kahuna-android/sdk" }
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "com.ryanc.android"
        minSdkVersion SDK.toInteger()
        targetSdkVersion 23
        versionCode V_CODE.toInteger()
        versionName "$APP_VERSION.$BUILD_NUMBER"
        multiDexEnabled true
    }
    signingConfigs {
        debug {
            storeFile file("$DEBUG_KEYSTORE_PATH")
            storePassword "$DEBUG_KEYSTORE_PASSWORD"
            keyAlias "$DEBUG_KEY_ALIAS"
            keyPassword "$DEBUG_KEY_PASSWORD"
        }
        release {
            storeFile file("$KEYSTORE_PATH")
            storePassword "$KEYSTORE_PASSWORD"
            keyAlias "$KEY_ALIAS"
            keyPassword "$KEY_PASSWORD"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    productFlavors {
        prod {
            applicationId "com.ryanc.android"
        }

        stage {
            applicationId "com.ryanc.android.stage"
        }

        qa {
            applicationId "com.ryanc.android.qa"
        }

        dev {
            applicationId "com.ryanc.android.dev"
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    def supportVersion = "23.1.1"

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':api')
    compile "com.android.support:support-v4:$supportVersion"
    compile "com.android.support:appcompat-v7:$supportVersion"
    compile "com.android.support:design:$supportVersion"
    compile 'com.facebook.android:facebook-android-sdk:4.8.1'
    compile 'uk.co.chrisjenx:calligraphy:2.0.1'
    compile "com.android.support:cardview-v7:$supportVersion"
    compile "com.android.support:recyclerview-v7:$supportVersion"
    compile "com.android.support:support-v13:$supportVersion"
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.5'
    compile 'com.fasterxml.jackson.core:jackson-core:2.4.5'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.5'
    compile 'joda-time:joda-time:2.5'
    compile 'com.squareup.retrofit:retrofit:1.7.1'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.netflix.rxjava:rxjava-core:0.20.7'
    compile 'com.netflix.rxjava:rxjava-android:0.20.7'
    compile 'com.squareup.dagger:dagger:1.2.2'
    compile 'com.squareup.mortar:mortar:0.16'
    compile 'com.squareup.flow:flow:0.8'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.jakewharton.timber:timber:2.5.1'
    compile 'com.braintreepayments:encryption:2.0.0'
    compile 'com.newrelic.agent.android:android-agent:5.3.2'
    compile 'com.instabug.library:instabugsupport:1.7.1'
    compile 'net.hockeyapp.android:HockeySDK:3.0.2'
    provided 'com.squareup.dagger:dagger-compiler:1.2.2'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.mixpanel.android:mixpanel-android:4.6.2'
    compile 'com.roomorama:caldroid:2.2.0'
    compile 'com.squareup.phrase:phrase:1.1.0'
    compile 'com.zendesk:sdk:1.5.0.1'
    compile 'com.flipboard:bottomsheet-core:1.4.3'
    compile 'com.kahuna.sdk:kahuna:2.3.1'
    compile 'io.branch.sdk.android:library:1.+''
}

【问题讨论】:

  • 能否也显示 build.gradle 文件?
  • 这可能是解决方案:stackoverflow.com/questions/24626180/…
  • @gerardnimo 添加了 build.gradle 文件。 piotrek1543 不幸的是,链接解决方案没有运气。
  • 我也有同样的问题。我回到了8.3.0。您有任何更新如何处理这个问题?

标签: android crash google-play-services


【解决方案1】:

play-services 库的版本应该相同,例如:

compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'

不要

compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'

【讨论】:

    【解决方案2】:

    在 8.4.0 上选择性编译 Google Play 服务 API 时,我也遇到了问题(8.3.0 -> 8.4.0)。

    错误:

    Could not find method com.google.android.gms.common.internal.zzx.zzy
    

    升级前:

    compile 'com.google.android.gms:play-services-maps:8.3.0'
    

    升级后(不起作用):

    compile 'com.google.android.gms:play-services-maps:8.4.0'
    

    升级后(工作正常):

    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    

    结论:似乎某些播放服务现在有一些您必须明确指定的特定依赖项,例如:maps -> gcm。

    【讨论】:

      【解决方案3】:

      我能帮你解决这个问题。我的同事能够毫无问题地升级。我去了我的 sdk/extras 文件夹,发现我的完全不同。所以我移动了我的文件夹,复制了我的同事,它起作用了。

      我认为该文件夹以及 sdk 文件夹中的其他内容刚刚进入一个奇怪的状态,清除文件夹并重新下载也可能有效。

      【讨论】:

      • 为我工作!我再次下载了 SDK,同步了所有内容,然后运行正常。谢谢!
      【解决方案4】:

      我刚遇到这个问题,但通过降级 gradle 版本解决了这个问题:

      旧的,麻烦的版本:

          classpath 'com.android.tools.build:gradle:2.2.0-rc2'
      

      固定版本:

          classpath 'com.android.tools.build:gradle:2.1.3'
      

      【讨论】:

        【解决方案5】:

        我刚才遇到了这个问题。我从 7.8.0 升级到 8.4.0 并收到与您相同的错误。重建和/或清理项目对我有用。

        【讨论】:

          【解决方案6】:

          我也遇到了同样的问题,通过正确配置proguard规则来解决这个问题。

          我在这里做了如下:

          首先,我在 proguard-rules.pro 中排除了 google 类的混淆:

          -keep public class com.google.** {*;}
          

          其次,我在 build.gradle 中启用了这个 minifyEnabled,如下所示:

          apply plugin: 'com.android.application'
          
          android {
              compileSdkVersion 23
              buildToolsVersion "23.0.3"
          
              defaultConfig {
                  applicationId "com.e2e.quiz"
                  minSdkVersion 15
                  targetSdkVersion 23
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      minifyEnabled true
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
          }
          
          dependencies {
              compile fileTree(include: ['*.jar'], dir: 'libs')
              testCompile 'junit:junit:4.12'
              compile 'com.android.support:appcompat-v7:23.1.1'
              compile 'com.android.support:recyclerview-v7:23.1.1'
              compile 'com.android.support:design:23.1.1'
              compile 'com.github.bumptech.glide:glide:3.6.1'
              compile 'com.squareup.picasso:picasso:2.4.0'
              compile 'com.google.android.gms:play-services-gcm:9.2.1'
              compile 'com.google.android.gms:play-services-analytics:9.2.1'
              compile 'com.google.android.gms:play-services-ads:9.2.1'
              compile project(':ast-dst')
          }
          

          【讨论】:

            【解决方案7】:

            我认为您应该包含相同版本的 -base 库。然后它再次开始工作。

            【讨论】:

              【解决方案8】:

              我在通过official tutorial 时遇到了同样的问题。

              解决办法是改变

              classpath 'com.google.gms:google-services:2.0.0-alpha6'
              

              classpath 'com.google.gms:google-services:3.0.0'
              

              我在sample on the github 中找到了正确的版本号。

              【讨论】:

                【解决方案9】:

                从 SDK 管理器中删除并重新安装 Google 服务并删除 your-project/.gradle/ 的内容为我解决了这个问题

                【讨论】:

                  【解决方案10】:

                  compile 'com.google.android.gms:play-services:+' compile 'com.google.firebase:firebase-core:+'

                  什么对我有用

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 2013-09-29
                    • 2021-05-28
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 2021-05-10
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多