7

今天,我将所有支持库和buildtools更新到最新版本,以支持Android N。一旦我更新了所有内容并运行了应用程序,我在我的应用程序中发现了InstanceId生成方法GCM的错误。所以,我搜索并找到了更新游戏服务的解决方案。在遵循所有的问题和答案之后,我陷入困境,无法前进。切换回支持库23.x.x不是一个选项,因为我想要针对Android N无法解决:com.google.android.gms:play-services-measurement:9.6.1

这里是build.gradle文件怎么我的项目层面看:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.0' 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

应用水平build.gradle

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url 'https://maven.fabric.io/public' } 
//  maven { url 'http://hansel.io/maven' } 
     maven { 
      url "https://jitpack.io" 
     } 
    } 

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
//  classpath 'io.hansel.preprocessor:preprocessor:1.0.+' 
    } 
} 


apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
//apply plugin: 'io.hansel.preprocessor' 


android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.2" 
    signingConfigs { 

    } 
    defaultConfig { 
     applicationId 'com.example.android' 
     multiDexEnabled true 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 47 
     versionName "1.3.2" 
     renderscriptTargetApi 24 
     renderscriptSupportModeEnabled true 
    } 
    buildTypes { 
     debug { 
      applicationIdSuffix = ".dev" 
      resValue "string", "app_name", "example-debug" 
     } 
     release { 
      minifyEnabled false 
      shrinkResources false 
      resValue "string", "app_name", "example" 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    productFlavors { 
     dev { 
      // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin 
      // to pre-dex each module and produce an APK that can be tested on 
      // Android Lollipop without time consuming dex merging processes. 
      minSdkVersion 21 
     } 
     prod { 
      // The actual minSdkVersion for the application. 
      minSdkVersion 16 
     } 
    } 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 
} 

repositories { 
    mavenCentral() 
    mavenLocal() 
    jcenter() 
    maven { url 'https://maven.fabric.io/public' } 
    maven { url "https://jitpack.io" } 
// maven { url 'http://hansel.io/maven' } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:support-v4:24.2.1' 
    compile 'com.android.support:support-annotations:24.2.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.facebook.android:facebook-android-sdk:4.3.0' 
    compile 'com.squareup.okhttp:okhttp:2.4.0' 
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' 
    compile 'com.android.support:recyclerview-v7:24.2.1' 
    compile 'com.android.support:cardview-v7:24.2.1' 
    compile 'com.squareup.retrofit:retrofit:1.9.0' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'com.github.clans:fab:1.6.1' 
    compile 'com.facebook.fresco:fresco:0.8.1+' 
    compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1+' 
    compile 'uk.co.chrisjenx:calligraphy:2.1.0' 
    compile 'com.google.android.gms:play-services-analytics:9.6.1' 
    compile 'com.google.android.gms:play-services-location:9.6.1' 
    compile 'com.google.android.gms:play-services-gcm:9.6.1' 
    compile 'com.google.android.gms:play-services-measurement:9.6.1' 
    compile 'com.github.liuguangqiang.swipeback:library:[email protected]' 
    compile 'me.imid.swipebacklayout.lib:library:1.0.0' 
    compile 'com.github.2359media:EasyAndroidAnimations:0.8' 
    compile 'com.theartofdev.edmodo:android-image-cropper:2.0.+' 
    compile 'com.wang.avi:library:1.0.1' 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.mixpanel.android:mixpanel-android:4.6.4' 
    compile 'com.github.ppamorim:dragger:1.2' 
    compile 'io.reactivex:rxandroid:1.1.0' 
    compile 'io.reactivex:rxjava:1.1.3' 
    compile 'com.jakewharton.rxbinding:rxbinding:0.2.0' 
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2' 
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' 
    compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1' 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.birbit:android-priority-jobqueue:2.0.0' 
    compile 'com.squareup:otto:1.3.8' 
    compile 'com.mikhaellopez:circularprogressbar:1.1.1' 
    compile 'com.github.dotloop:aosp-exif:be25ae51ec' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     exclude group: 'com.squareup.okhttp', module: 'okhttp' 
     transitive = true; 
    } 
} 
apply plugin: 'com.google.gms.google-services' 

这是我收到的错误: enter image description here

任何帮助受到高度赞赏。谢谢。

编辑

我的谷歌播放服务也更新。 enter image description here

回答

2

最后,我自己解决了。下面是我做的:

  1. 删除compile 'com.google.android.gms:play-services-measurement:9.6.1',然后编译该项目
  2. 它给missing api_key error因为GCM得到转移到Firebase等等google-services.json文件不起作用
  3. 要解决这个问题,只需更新google-services.json文件与使用Firebase中的云消息传递的新生成的文件
  4. 之后,我编译并得到@drawable/powered_by_google_dark从项目中缺失的另一个错误,因为我正在使用Places自动完成API。要解决此问题,请将compile 'com.google.android.gms:play-services-places:9.6.0'添加到依赖项
2

您没有最新的google play服务,只需点击链接,android studio会提供一个对话框来安装它。

+3

我点击链接,什么都没有发生。 –

+0

您是否尝试过使用9.6.0而不是9.6.1。我不认为有一个9.6.1但我尝试过 – sativa

+0

,同样的问题。 –

1

将所有播放服务依赖关系设置为9.6.0。 9.6.1还没有发布。如果问题仍然存在,请在您的android studio中安装最新的Google Play服务和存储库。

+0

我将所有依赖关系更改为9.6.0,但仍然出现相同的错误。另外,我的播放服务也进行了更新。查看编辑。 –

+1

尝试在您的项目级别build.gradle'classpath'com.google.gms:google-services:3.0中更改此行。0''到'classpath'com.google.gms:google-services:2.1.0''。从[this](https://github.com/googlesamples/google-services/issues/229)参考中找到了这一点。 –

+0

仍然是同样的问题。 –

5

今天我遇到了同样的问题。这解决了我的问题:

打开独立的Android SDK管理器。在附加部分,“Google Play服务”是最新版本,但在将“Google Repository”从版本33更新为35之后的“Google Repository”中,问题消失了。

+0

我有一个类似的问题...在升级Android/Studio和SDK期间崩溃了。当我回到SDK Manager时,根本没有安装Google Play Services和Google Repository。 (重新)安装后,事情工作正常。 – tir38