2015-11-05 60 views
14

將我的谷歌播放服務更新至第28版後,我收到此錯誤。我不知道爲什麼這會發生,因爲它以前工作正常。錯誤:執行任務':app:processDebugGoogleServices'失敗。 >請修復版本衝突

這裏是我的的build.gradle文件

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 
android { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.2' 

defaultConfig { 
    applicationId "com.matsoltech.pakistancurrentaffairs" 
    minSdkVersion 10 
    targetSdkVersion 23 
    versionCode 11 
    versionName "2.1.1" 
} 
buildTypes { 
    release { 
     multiDexEnabled = true 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile files('src/main/libs/universal-image-loader-1.9.3.jar') 
    compile files('src/main/libs/nineoldandroids-2.4.0.jar') 
    compile 'com.android.support:appcompat-v7:23.1.0' 
    compile 'com.android.support:support-v4:23.1.0' 
    compile 'com.android.support:cardview-v7:23.1.0' 
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.0' 
    compile 'com.google.android.gms:play-services:8.3.0' 
    compile 'com.mcxiaoke.volley:library:1.0.18' 
    compile 'com.google.android.gms:play-services-analytics:8.3.0' 
} 

buildscript { 
repositories { 
    jcenter() 
} 

dependencies { 
    classpath 'com.android.tools.build:gradle:1.3.0' 
    classpath 'com.google.gms:google-services:1.4.0-beta3' 
    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
} 
} 

allprojects { 
repositories { 
    jcenter() 
} 
} 

那麼,誰能告訴我問題出在哪裏?因爲代碼在更新GooglePlayServices之前工作正常。

回答

27

改變你的谷歌服務的項目依賴於

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

這將解決這個問題。

+0

修好了,非常感謝! Google忘記了更新他們的官方文檔。它仍然提到classpath'com.google.gms:google-services:1.4.0-beta3' –

+2

巨大的感謝之手,當Google對我們做這件事時討厭它:/ – awaistoor

+1

谷歌告訴開發者放這個類路徑?我沒有看到com.google.gms:google-services:1.4.0-beta3 classpath或'com.google.gms:google-services:1.5.0-beta2' – aeroxr1

3

如果您僅使用播放服務 - 分析: 刪除此

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

整個庫是沉重的。現在你可以拿走你需要的部分。 Analitycs,GCM等 所以你實際上是兩次服用(分析)

+0

我之前試過這個,但沒有解決問題。 – awaistoor

0

試試這個

dependencies { 
    classpath 'com.android.tools.build:gradle:2.0.0-alpha3' 
    classpath 'com.google.gms:google-services:2.0.0-alpha3' 
} 
+0

雖然此代碼塊可能會回答問題,但請提供相關信息,以便其他人可以從中受益。 – SMR

7

使用這些依賴關係爲項目的build.gradle

dependencies { 
    classpath 'com.android.tools.build:gradle:2.3.1' 
    classpath 'com.google.gms:google-services:3.0.0' 
} 

,並把此在的結束應用程序級build.gradle文件(在依賴關係之後)。出於某種原因,我不明白你是否在開始時會引起問題,請確保將它放在最後。

apply plugin: 'com.google.gms.google-services' 
+1

從哪裏得到這個信息使用2.0.0-aplpha3? 也是穩定的使用alpha3依賴? –

+0

謝謝!如果我不知道將插件移動到列表底部,我會花一整天的時間修復這個問題! –

3

目前的版本是2.0.0-beta6 ......從頂端移到

apply plugin: 'com.google.gms.google-services' 

到依賴後的底部,儘管建議這樣做,我把它添加到底部並沒有意識到它已經在頂端。偶然發生了兩次使我惱火。

+0

我注意到你應該把'apply plugin'從你的註釋中放到gradle文件的*底部,並且它解決了我的問題。謝謝! – murgo

0

你必須物理導入谷歌,services.json在您的項目所在 例如:C:\用戶\用戶\桌面\ yourproject \

把你的谷歌服務。JSON在這裏yourprojects的app文件夾 C:\用戶\用戶\桌面\ yourproject \應用< ----------在這個

4

您需要添加此

dependencies { 
     compile 'com.google.android.gms:play-services:9.6.1' 
} 

和刪除這個

apply plugin: 'com.google.gms.google-services' 
0

我也有同樣的問題,當我是Android開發的新手。 彷彿你已經到位像下面

compile 'com.google.android.gms:play-services:10.0.1' 
compile 'com.google.firebase:firebase-messaging:10.0.1' 

,你可能會被放在了下文線在你的build.gradle(應用層)的一切

apply plugin: 'com.google.gms.google-services' 

把上面這段代碼在build.gradle修復你的錯誤

更重要的是檢查你的build.gradle(項目級別)文件

apply plugin: dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.3' 
     classpath 'com.google.gms:google-services:3.0.0' 
    }' 

com.google.gms:谷歌服務:3.0.0放置或沒有。它不支持老verisons

0

確保播放服務的版本是,你使用的

最新
0

要解決此錯誤,轉到項目 - >平臺..>機器人 - > gradlefile並修改該行

buildscript { 
    repositories { 
      jcenter() 
      mavenLocal() 
     } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:+' 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 
// apply plugin: 'com.google.gms.google-services' 
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file 
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin 
0

我遇到了這個問題,太。你說的不是關鍵。

dependencies { 
compile 'com.google.android.gms:play-services-auth:11.6.2' 
compile 'com.google.android.gms:play-services-plus:11.6.2' 
} 
apply plugin: 'com.google.gms.google-services' 

此應用插件:'com.google.gms.google-services'必須在依賴關係!

相關問題