2

I have updated from Android Studio 4.0 to 4.1. After the update I cannot build my application anymore which worked fine before the update. When I build the project I am getting the following exception:

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':app:compressDebugAssets'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CompressAssetsWorkAction my\application\path\app\build\intermediates\merged_assets\debug\out

The folder my\application\path\app\build\intermediates\merged_assets\debug\out is empty.

What I tried to do:

  • Clean and rebuild the project
  • delete the .gradle and the build folder and clean an rebuild the project
  • invalidate and restart Android studio
  • Increased the heap size in gradle.properties to: org.gradle.jvmargs=-Xmx4096m
  • Increased the compileSdkVersion and targetSdkVersion
  • Installed and updated the buildToolsVersion from 30.0.0 to 30.0.2
  • Added multiDexEnabled true to my config

My gradle configuration looks like this:

apply plugin: 'com.android.application' android { compileSdkVersion 'android-R' buildToolsVersion "30.0.2" defaultConfig { applicationId "my.application.id" minSdkVersion 23 targetSdkVersion 29 versionCode 2 versionName "1.1" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } repositories { mavenCentral() maven { url 'https://maven.google.com' } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.2.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.2' implementation 'androidx.navigation:navigation-fragment:2.3.1' implementation 'androidx.navigation:navigation-ui:2.3.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' testImplementation 'junit:junit:4.13.1' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' implementation "androidx.room:room-runtime:2.2.5" annotationProcessor "androidx.room:room-compiler:2.2.5" implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'androidx.multidex:multidex:2.0.1' } 

Guys, I am out of ideas as I am no expert when it comes to gradle. Help would be most appreciated.

2
  • What is your gradle and android plugin version? Commented Dec 2, 2020 at 14:58
  • Your minSdkVersion is 23 you don't need implementation 'androidx.multidex:multidex:2.0.1' and vectorDrawables { useSupportLibrary = true}. Try to remove them. Commented Dec 2, 2020 at 15:18

6 Answers 6

4

I found a temporary solution in downgrading my Android Studio version to 4.0.2.
Additionally, I changed the Android gradle plugin version to 4.0.2 and the gradle version to 6.1.1 which I had installed before. You can do this under
File -> Project Structure -> Project.
Now I am able to run my application again. I am aware that this is only a temporary solution but at least I can work again on my application.
I will try to install Android Studio 4.2 Canary 15 the next days and check, if this works for me. I let you know.

Sign up to request clarification or add additional context in comments.

Comments

0

This is what usually works for me every time i make an update, I hope it works for you.

Sometimes gradle build fails because, downloading some dependencies required by gradle for a successful build are missing and need to be downloaded. So make sure your computer is online.

-> Click on gradle (right side of your android studio), then toggle the highlighted button in the pic below.

  1. Make sure its not highlighted, Cause if it is highlighted that means gradle is offline (has no access to internet)

  2. Then rebuild project to download the missing gradle dependencies.

enter image description here

I hope you find this useful.

1 Comment

Thank you for your answer. Unfortunately, this did not do the trick for me. The button was already not highlighted and I have a stable internet connection.
0

this solution may help. I had problems with this error showing up and I had no idea why. As it turns out, I save my android projects to a USB stick. The USB stick is formatted using PAL. I reformatted using NTFS and the problem has gone.

1 Comment

I'm not sure that formatting a USB stick fixes Android Studio migration. Seems like you've done a good job with something else but didn't notice it was a fix:)
0

I had a similar problem this morning after updating my Android studio. In my case, previous projects run well but if I create a new project and attempt to run, I will get the said error message. I changed the Android Gradle plugin version to 4.0.2 and the Gradle version to 6.1.1 from the project structure dialog and I was able to run the app successfully afterward.

Comments

0

I have this problem when I try to build apk with capacitor Ionic in Android Studio. My solution was:

First change the Android Gradle plugin in build.gradle to classpath 'com.android.tools.build:gradle:4.0.2' and in gradle-wrapper.properties change Gradle version to distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip and press Sync Now.

When gradle sync is finish, close Android Studio Editor and go to project folder and inside android delete .idea and .gradle folders. Next you need to open PowerSheel in this location and run the code .\gradlew clean.

Finally, you can open the project with android studio using in vs npx cap open android or as you want, wait for sync gradle and then you can build your apk.

Comments

-2

Changing the location my projects from a FAT32 formatted drive to an NTFS drive solved the problem for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.