Daniel Botnik
Daniel Botnik

Reputation: 669

Gradle - Null extracted folder for artifact: ResolvedArtifact

I've the following line in my gradle android project inside the module build.gradle

dependencies {
 // a lot of dependencies
 implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly-SNAPSHOT'
}

and it causes the gradle build to fail with the following error

Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly-SNAPSHOT:20210331.060351-75, variantName=null, artifactFile=C:\Users\USER\.gradle\caches\modules-2\files-2.1\org.tensorflow\tensorflow-lite-select-tf-ops\0.0.0-nightly-SNAPSHOT\b03a88bda4ad93e6fefe285f9ea303d28433eacc\tensorflow-lite-select-tf-ops-0.0.0-nightly-SNAPSHOT.aar, extractedFolder=null, dependencyType=ANDROID, isWrappedModule=false, buildMapping={__current_build__=C:\Users\USER\Desktop\Myapp2}, mavenCoordinatesCache=com.android.build.gradle.internal.ide.dependencies.MavenCoordinatesCacheBuildService$Inject@5c4450a)

I had the same implementation in a diffrent project and it worked but in this project this error keep on appearing.

what causes this error? and how can I fix it?

Upvotes: 30

Views: 61248

Answers (11)

Fisher
Fisher

Reputation: 21

I solved this issue by upgrading AGP version from 4.2 to 7.0

In the build.gradle file:

    buildscript { 
    ext {
        agp_version = '7.0.0'
    }

    dependencies {
        classpath "com.android.tools.build:gradle:$agp_version"
    }
    }

Upvotes: 1

mihai71
mihai71

Reputation: 372

After editing the path to AAR library, as mentioned by others (implementation...), I also had to specifically sync project with Gradle. From the meniu File -> Sync Project with Gradle files . In Android Studio Chipmunk 2021.2.1

Upvotes: 0

tips technos
tips technos

Reputation: 11

implementation 'androidx.activity:activity:1.8.0' 

Remove this line from gradle.build and resolve the issue

Upvotes: 1

M. Massula
M. Massula

Reputation: 4800

In my case I had to go to the equivalent folder:

C:\Users\USER\.gradle\caches\modules-2\files-2.1\org.tensorflow\tensorflow-lite-select-tf-ops

And delete it, then try to sync again, and worked.

Upvotes: 2

Mittal Patel
Mittal Patel

Reputation: 6089

In my case, an Artifact error was generated After Project migrated from Android to AndroidX

Error was

Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=androidx.activity:activity:1.8.0, variantName=null, artifactFile=/home/mittal/.gradle/caches/modules-2/files-2.1/androidx.activity/activity/1.8.0/4266e2118d565daa20212d1726e11f41e1a4d0ca/activity-1.8.0.aar, extractedFolder=null, dependencyType=ANDROID, isWrappedModule=false, buildMapping={__current_build__=/home/mittal/StudioProjects/android/android-sdk}, mavenCoordinatesCache=com.android.build.gradle.internal.ide.dependencies.MavenCoordinatesCacheBuildService$Inject@6fbb61c0)

Excluding Activity library from material dependencies solved the error

    implementation ('com.google.android.material:material:1.10.0') {
    exclude group: 'androidx.activity', module: 'activity'
}

So if you are facing the artifact error then check the library mentioned in the error and Try removing that library may help you.

Upvotes: 0

dotrinh DM
dotrinh DM

Reputation: 1393

When importing arr/jar to AS, I have encountered this issue. My method is switching Project view to Project mode (not Android mode) and after that add aar/jar to libs folder (or any folder)

dotrinh

Upvotes: 0

ButterCYassine
ButterCYassine

Reputation: 21

You must check the path well for example:

implementation(files("./src/libs/myfile.aar")) 

or

implementation files("./src/libs/myfile.aar")

Upvotes: 2

Maciej S
Maciej S

Reputation: 1042

In my case I had to increase amount of RAM to 4096 in gradle.properties:

org.gradle.jvmargs=-Xmx4096M

After that project synced correctly.

Upvotes: 43

Morgan Koh
Morgan Koh

Reputation: 2465

Well, you can be more explicit like this.

implementation files("$rootProject.projectDir/libs/test.aar")

Upvotes: 0

Vinay Sharma
Vinay Sharma

Reputation: 91

I got the error when I was adding unit-ads.aar . I changed this in my code and its works for me.

Old Code

implementation files('../libs/unity-ads.aar')

New Code

implementation files('libs/unity-ads.aar')

Upvotes: 8

Umut Gültekin
Umut Gültekin

Reputation: 496

I got the same error when I was adding aar. I changed the implementation path and then fixed.

old path

implementation files('libs/test.aar')

new path

implementation files('../libs/test.aar')

Upvotes: 48

Related Questions