My android application using Kotlin is throwing this exception when I try to Run 'app' in the emulator o in my cellphone. When I build my project it runs well, with no errors.
I am using:
- SDK 28 (Android 9.0 (Pie))
- Gradle 5.1.1
- Gradle Plugin 3.5.0-alpha03
- Kotlin 1.3.10
- Java 1.8.0_151
- OSX 10.13.2
org.gradle.internal.exceptions.LocationAwareException: buildOutput.apkData must not be null
at org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:99)
at org.gradle.initialization.exception.DefaultExceptionAnalyser.collectFailures(DefaultExceptionAnalyser.java:65)
at org.gradle.initialization.exception.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:39)
at org.gradle.initialization.exception.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:29)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:194)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:141)
...
Caused by: java.lang.IllegalStateException: buildOutput.apkData must not be null
at com.android.build.gradle.internal.ide.EarlySyncBuildOutput$Companion$load$2.invoke(EarlySyncBuildOutput.kt:103)
at com.android.build.gradle.internal.ide.EarlySyncBuildOutput$Companion$load$2.invoke(EarlySyncBuildOutput.kt:67)
at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:174)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:691)
at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:721)
at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:712)
...
In my case build and launch project with different build configs was successful. But generating signed apk throws error
Cause: buildOutput.apkData must not be null
on the other hand apk was generated and Build Output toggle view printsBUILD SUCCESSFUL
. Manual installation ends with messageApp not installed
. My fault was usingcompileSdkVersion 'android-P'
and after changing tocompileSdkVersion 28
all goes well.All the solutions didn't work with me
In my case from AndroidStudio 3.4+ update to 3.5.
And finally I solve it by modify 'Destination Folder' to "app/build/outputs/apk"
detail pic
Updating to Android Studio 3.4.?, i get the message
looking for an answer i found the procedure:
Build
->Clean Project
but it doesn´t worked, i know that this procedure will delete the content into the
/build
directory but for my experience it doesn´t work in all cases, so i tried the "raw" way, deleting the directory:then i rebuild the project and it worked.
FOR Android Studio 3.5
debug builds finish without any error. During the creating a signed .apk leads to the same error
the Simple solution that I found is. During the signing the apk after entering the signing credentials when you navigate to the next screen then it will ask for the destination folder just change the default path.
Let's assume current destination path is
change it to
then it will generate the signed apk successfully.
I tried above multiple solutions but nothing has happened then I found this this and worked for me
Now I am able to generate apk
1- Delete all generated app bundles (.aab) and APKs for all variants.
2- Delete the build folder
3- clean project