6

This is my 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'
}

when I run my project I see this errors

Error:(59, 8) error: cannot access ActivityCompatApi23 class file for android.support.v4.app.ActivityCompatApi23 not found

and

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

How can I fix this problem ??? :(

3 Answers3

12

I solved this problem by add this code in 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'
            }
        }
    }
}
2

All support libraries need to be same version. If your compile SDK is 25,it's 25.3.0. If your compile SDK is 26, it's 26.0.0. Don't mix them

this should fix your problem

  compile 'com.android.support:appcompat-v7:25.3.0'
  compile 'com.android.support:recyclerview-v7:25.3.0'
Ali Asadi
  • 987
  • 10
  • 13
1

I just changed the line

compile 'com.android.support:appcompat-v7:26.0.0-alpha1'

to

compile 'com.android.support:appcompat-v7:26.+'
Surhan Zahid
  • 351
  • 4
  • 8