2017-06-20 11 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'保存了我的项目,以及很多家伙。

相关问题