2017-06-20 10 views
10

我有一個問題,並查看了可能的重複問題和答案,我認爲這個問題沒有得到其他人的回答,所以在此處詢問。compile appcompat v7:26. +爲融合位置提供商添加播放服務時出錯

我更新了我的播放服務以利用融合位置提供程序,現在我的gradle中的appcompat顯示錯誤。

因此,我創建了一個新項目,並檢查了新項目上的build.gradle,並且具有完全相同的appcompat,但是我的項目顯示錯誤。

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 26 
buildToolsVersion "26.0.0" 
defaultConfig { 
    applicationId "au.com.itmobilesupport.sqltwo" 
    minSdkVersion 17 
    targetSdkVersion 26 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:26.+' 
compile 'com.android.support:recyclerview-v7:26.+' 
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' 
testCompile 'junit:junit:4.12' 
compile 'com.google.android.gms:play-services-maps:11.0.0' 
compile 'com.google.android.gms:play-services:11.0.1' 
} 

其此行是顯示錯誤:

compile 'com.android.support:appcompat-v7:26.+' 

但在新項目中的罰款。爲什麼我會收到錯誤?

UPDATE:

如果我刪除這兩條線,則錯誤消失:

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

但我需要他們,所以仍然有錯誤。

+1

看起來只是導致錯誤的com.google.android.gms:play-services行。仍在挖掘解決方案 – timv

回答

4

終於在ZeroOne's answer的幫助下解決了類似問題。

是什麼讓我看到ZeroOnes的答案是谷歌給我的原因,但不是一個錯誤。我的問題是,下面這行太過於複雜,並且增加了很多額外的依賴關係,這會使應用程序不必要地變大。

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

我只是需要更具體和錯誤消失。

這是最後的gradle。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.0" 
    defaultConfig { 
     applicationId "au.com.itmobilesupport.sqltwo" 
     minSdkVersion 17 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support:recyclerview-v7:26.+' 
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' 
    testCompile 'junit:junit:4.12' 
    compile 'com.google.android.gms:play-services-maps:11.0.1' 
    compile 'com.google.android.gms:play-services-location:11.0.1' 
} 

這是specifc線我改變了上面:

compile 'com.google.android.gms:play-services-location:11.0.1' 

希望它可以幫助別人誰在同樣的問題來了。

+1

請檢查一下,因爲這非常有幫助。 https://developers.google.com/android/guides/setup – timv

+0

我沒有任何播放服務代碼,但仍然得到這個,即使(更新後)我開始一個新的新項目。我曾嘗試使用確切的版本號,無濟於事。這個StackOverflow文章是當我精確搜索這個特定錯誤(添加「避免使用+等等等等」)時Google返回的唯一網頁。 – Joshua

5

將這些行添加到您的build.gradle文件中,以獲取您沒有的文件,然後根據Google site

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
} 

Caution: Using dynamic dependencies (for example, palette-v7:23.0.+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a library version (for example, palette-v7:25.4.0)

+0

這對我有效,謝謝。 – user4500

+0

@ user4500,我很高興它幫助了某人。 –

+0

沒有工作到我的項目 –

0

使用compile'c​​om.google.android.gms:play-services-location:11.0.1'更具體,而不是編譯'com.google.android.gms:play-services:11.0.1'保存了我的項目,以及很多傢伙。

相關問題