Ajay Kulkarni
Ajay Kulkarni

Reputation: 3039

Build fails in Android Studio 4.1

I installed Android Studio 4.1 recently, tried to run a sample project in Android Studio 4.1. Got this error:

A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
java.lang.IllegalArgumentException (no error message)

So I modified few lines as given below:

  1. Changed gradle.properties as
    org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
    to
    org.gradle.jvmargs=-Xmx4608m -Dfile.encoding=UTF-8

  2. Updated minSdkVersion to 21

  3. Added Multidex support

    def multidex_version = "2.0.1" implementation "androidx.multidex:multidex:$multidex_version"

I even tried invalidate caches and restart.

My classspath is classpath "com.android.tools.build:gradle:4.1.0" and gradle version is gradle-6.5.

I made sure that Android Studio 4.1 meets minimum compatibility as given in this link.

Then I tried to install the sample app in device. I got this error:
Execution failed for task ':app:packageDebug'.

A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable java.lang.IllegalArgumentException (no error message)

What is causing this? Is this a bug?

Upvotes: 0

Views: 3696

Answers (2)

sunwei
sunwei

Reputation: 371

delete output path of apk files, ex: app/build/outputs/apk

Upvotes: 0

Ajay Kulkarni
Ajay Kulkarni

Reputation: 3039

I managed to fix it...
You have 3 options to fix that error (Error in question)

  1. Add Multidex Support
    Add these lines in dependencies

    def multidex_version = "2.0.1"
    implementation "androidx.multidex:multidex:$multidex_version"
    Add this line to defaultConfig:
    multiDexEnabled true
    Sync your project, see if that fixes your error.

  2. If option 1 doesn't work, try increasing jvmargs Add this line in gradle.properties:
    org.gradle.jvmargs=-Xmx4608m -Dfile.encoding=UTF-8
    Sync and run your project.

  3. If both options don't work, then delete .gradle and build folder in your project's directory. Run Clean project and Rebuild project. Then run the project.
    NOTE: If above options doesn't work, then invalidate caches and restart.

Upvotes: 9

Related Questions