这是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
defaultConfig {
applicationId "com.example.user2.trafficmap"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url "https://maven.google.com" }
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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 'io.nlopez.smartlocation:library:3.3.3'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.github.arimorty:floatingsearchview:2.1.1'
compile 'com.google.android.gms:play-services-places:11.4.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:26.0.0'
}
当我运行我的项目时,我看到了这个错误
错误:(59,8)错误:无法访问ActivityCompatApi23类文件 找不到android.support.v4.app.ActivityCompatApi23
和
错误:任务':app:compileDebugJavaWithJavac'执行失败。
编译失败;有关详细信息,请参阅编译器错误输出。
我该如何解决这个问题? :(
答案 0 :(得分:9)
我通过在build.gradle
中添加此代码解决了这个问题configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
答案 1 :(得分:2)
所有
support
库都需要是相同的版本。如果您的编译SDK是25,那么它是25.3.0。如果您的编译SDK是26,那么它是26.0.0。不要混合它们
这应该可以解决您的问题
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
答案 2 :(得分:0)
我刚改变了行
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
到
compile 'com.android.support:appcompat-v7:26.+'