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)
...
the only solution that works for me is using in my root gradle
what i've tried : - clear all build folder manually - invalidate cache but none of these is work
PS: i'm using android studio 3.5 btw
Update :
just like @Vishrut Mavani, changing the destination folder of your release version is work
Step 1: I have resolved this issue by modifying the Destination Folder location.
Before
After
Step 1: After update Android Studio 3.4 you need to add all the dependency that used in your module or library in your app-level
build.gradle
.Step 2: Clean Project(Build > Clean Project)
Step 3: Rebuild Project(Build > Rebuild Project)
Now, Your Project will compile Perfectly.
I have android studio 3.5.1 . For me below steps are worked
All the solutions didn't work with me
Android Studio V 3.5
Android gradle plugin V 3.4.2
Gradle Version V 5.1.1
Reference
I was getting this error also, when trying to "Generate Signed APK" for my release version. I tried all of the above methods, unfortunately none worked for me.
What worked, was generating first the debug signed version of the app, and then generating again the release one.
I do not know what exactly changed or what the original problem was, but it worked. I hope it will help you too, because this error is quite annoying...
Usually this issue happen on updating android Studio V3.4 to V3.5. Try to delete
debug/output.json
andrelease/output.json
files.Then Try these steps:
Step 1: Clean Project(Build > Clean Project)
Step 2: Rebuild Project(Build > Rebuild Project)