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