Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More than one file was found with OS independent path 'classes.jar' & 'com.android.tools.build:gradle:3.5.0'

Tags:

android

update to 'com.android.tools.build:gradle:3.5.0'

find the build error:

Execution failed for task ':truecp_player:mergeDebugJavaResource'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade More than one file was found with OS independent path 'classes.jar'

ps: 'com.android.tools.build:gradle:3.4.2' work fine.

update: if the library module with some local .aar file dependency the error will occur!

library module:

apply plugin: 'com.android.library'

def androidConfig = rootProject.extensions.getByName("ext").android

android {
    compileSdkVersion androidConfig.compileSdkVersion
    buildToolsVersion androidConfig.buildToolsVersion

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    api fileTree(include: ['*.jar', "*.aar"], dir: 'libs')

    implementation 'androidx.appcompat:appcompat:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}


like image 346
庄 鹏 Avatar asked Aug 30 '19 10:08

庄 鹏


1 Answers

I had exactly the same issue and it was caused by .aar and .jar libraries. Looks like you also include some of them in your project:

api fileTree(include: ['*.jar', "*.aar"], dir: 'libs')

In my particular case one of .aar files also contained .jar file with the same name as another .jar file from the /libs folder. Also, I had to change the way of importing .aar files: from /libs folder to independent gradle modules as described in the official docs and here.

like image 60
fraggjkee Avatar answered Oct 22 '22 14:10

fraggjkee