Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ??? :(

like image 720
Mostafa Pirhayati Avatar asked Jan 03 '18 07:01

Mostafa Pirhayati


3 Answers

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'
            }
        }
    }
}
like image 126
Mostafa Pirhayati Avatar answered Nov 20 '22 12:11

Mostafa Pirhayati


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'
like image 2
Ali Asadi Avatar answered Nov 20 '22 12:11

Ali Asadi


I just changed the line

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

to

compile 'com.android.support:appcompat-v7:26.+'
like image 1
Surhan Zahid Avatar answered Nov 20 '22 14:11

Surhan Zahid