Cause: buildOutput.apkData must not be null
Solution 1
Click Build
-> Clean Project
Then Build
-> Make Project
Tested on gradle 3.5.0-alpha3, -alpha5 and 3.4.0 (project gradle)
classpath 'com.android.tools.build:gradle:3.5.0-alpha03'
Solution 2
For Android Studio 3.5 & 3.6 Update (APK signed issue)
Step 1: I have resolved this issue by modifying the Destination Folder location.
Before
c:\user\folder\project\app
After
c:\user\folder\project\apk
For Android Studio
3.4
Update.
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.
Solution 3
FOR Android Studio 3.5 | 3.6
debug builds finish without any error. Creating a signed .apk leads to the same error
buildOutput.apkData must not be null
the Simple solution that I found is. During the signing of 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 the current destination path is
c:\user\folder\project\app
change it to
c:\user\folder\project\
then it will generate the signed apk successfully.
Solution 4
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...
Solution 5
Cleaning the project didn't help me but manually deleting all the auto-generated build folders in all modules helped.
Related videos on Youtube
jzelar
Updated on February 16, 2022Comments
-
jzelar about 2 years
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) ...
-
Eugen Martynov about 5 yearsI created a ticket issuetracker.google.com/issues/129994596
-
Andrew about 5 yearsI have the same after I updated Android Studio to 3.4
-
Nicky about 5 yearsCheck Lemberg answer that works for me, I've faced that issue today
-
Patapoom over 4 yearsSame for Java (not necessary Kotlin) after installing Android Studio 3.5.
-
kikoso about 5 yearsI can confirm this is working as well with the version
com.android.tools.build:gradle:3.5.0-alpha05
(withBuild
->Rebuild Project
in AS) -
luckyhandler about 5 yearsAlso works for
classpath 'com.android.tools.build:gradle:3.4.0-rc02'
-
void.pointer about 5 yearsSadly it requires upgrading to Android Studio 3.5, I can't tell my team to switch to an unstable channel for Android Studio updates.
-
devgianlu about 5 yearsThis is the equivalent of cleaning the project.
-
Roman Nazarevych about 5 yearsNo, it isn't, try to clean project from Android Studio and then check App directory for
build
directories in any file explorer, you will see that some files are still left there. -
Martin Pfeffer about 5 years@void.pointer why not? I'm on canary (also for production) for years. Can't complain about stability or bad performance (using macOS)..
-
Rafael about 5 yearsWorks on Android Studio 3.4
-
林果皞 about 5 yearsIn my case I need to generate first product flavor apk (debug to release) to last flavor (debug to release).
-
Doongsil almost 5 yearsYes!! It worked for me too. thanks. I don't know why but it looks like a bug.
-
Hari almost 5 yearsIn my case I had multiple flavours, it worked once I had deleted all the build folder along with Flavour specific folders. After deleting folders, I had to close the project and reopen to get it working
-
babay almost 5 yearswhat's that? what should I do exactly? > 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.
-
VIISHRUT MAVANII over 4 years@babay Suppose you are using any library that is using Glide library. Then you have to add your Glide dependency in your App level build.gradle also.
-
Mihodi Lushan over 4 yearstrying on AndroidStudio3.5 on Mac OS, all sdk updated, using gradle version
com.android.tools.build:gradle:3.5.0
, this solution is not working for me -
Mihodi Lushan over 4 yearstrying on AndroidStudio3.5 on Mac OS, all sdk updated, using gradle version
com.android.tools.build:gradle:3.5.0
, this solution is not working for me -
Mihodi Lushan over 4 yearstrying on AndroidStudio3.5 on Mac OS, all sdk updated, using gradle version
com.android.tools.build:gradle:3.5.0
, this solution is not working for me -
Mihodi Lushan over 4 yearstrying on AndroidStudio3.5 on Mac OS, all sdk updated, using gradle version
com.android.tools.build:gradle:3.5.0
, this solution is not working for me -
Mihodi Lushan over 4 yearstrying on AndroidStudio3.5 on Mac OS, all sdk updated, using gradle version
com.android.tools.build:gradle:3.5.0
, this solution is not working for me -
Suresh Maidaragi over 4 yearsCan you try File > Invalidate caches/Restart after delete auto-generated files .gradle and build @MihodiHasanLushan
-
Martin Pfeffer over 4 years@MihodiHasanLushan Delete the
build
folder and build project again. Otherwise check if your gradle is correct (sdk, dependencies, etc). Are you sure you are getting the same error message? -
Mihodi Lushan over 4 yearstried those, yes, I am getting this error. @MartinPfeffer
-
ghita over 4 years@MihodiHasanLushan for me it works only after i'ved run 'gradlew clean build' on android studio's terminal. i am using
classpath 'com.android.tools.build:gradle:3.5.0'
with android studio 3.5 on windows10 -
Loadeed over 4 yearsThis "solution" also worked for me. Downgrade to AS 3.4.2, downloadhere: developer.android.com/studio/archive and changing from 3.5.0 to: classpath 'com.android.tools.build:gradle:3.4.2'
-
solo over 4 yearsIn my case: AndroidStudio3.5, Build bundle(s)/apk(s) => Build apk(s), then Generate Signed APK
-
Patapoom over 4 yearsWorks on Android Studio 3.5.
-
javaxian over 4 yearsThis worked for me, but I had to also remove all
<flavor>/<buildConfig>
directories (it's aboutoutput.json
files in them).Clean project
alone didn't solve the issue. -
cVoronin over 4 yearsIt is crazy, but this solution works - I don't understand why. Android Studio 3.5, Windows
-
Apparao Mulpuri over 4 yearsIts a bug in Android Studio 3..5
-
james over 4 yearsi got this error after step 3. APT: error: resource android:attr/fontStyle not found.
-
VIISHRUT MAVANII over 4 years@james I think there is a resource missing. follow the below steps to find an issue. Click on Gradle(You will find in Top-Right Corner) > app_name(root) > other > assembleDebug
-
james over 4 yearsI really appreciate your solution. Thanks. This is just simple and just really stupid build error of Android Studio.
-
james over 4 years@VishrutMavani Thank for your answer, but i found the really stupid error of Android studio. I just changed the build output path. That is. Solution by Shuham Jain. See below his solution.
-
Vijay Kumar Kanta over 4 yearsWow, you saved my life with this. However is this a bug in Android Studio or is my project messed up?
-
Shubham Jain over 4 years@ Vijay Kumar Kanta this is an issue with the studio I hope in the new update it will be fixed
-
Henrique Monte over 4 yearsOMG, this Android Studio upgrade to 3.5 brings a lot of issues for me.
-
buncis over 4 years'Destination Folder' is a field in Generate Signed Bundle or APK modal;
-
dodgy_coder over 4 yearsThis fixed my issue in Android Studio v3.5 and a Java project. This is a pretty standard occurrence whenever building Android apps now ... (1) get a weird incomprehensible build error (2) google it (3) stack overflow (4) apply seemingly unrelated workaround in a specific order (5) pray (6) it works (7) go to step (1)
-
Juan José Melero Gómez over 4 yearsI only had to clean since my gradle version was 3.5.1 when I updated my project fro my repo.
-
CodeFluid over 4 yearsVery useful in Android 3.5.2
-
mkasberg over 4 yearsI can't believe the working solution to this problem is actually "Change the destination folder." But it is! ¯\_(ツ)_/¯
-
Billyjoker over 4 yearsi do not know where is suppossed to change that directory. I have not figured out yet
-
VIISHRUT MAVANII over 4 years@Billyjoker During the signing 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.
-
Nuwan Withanage over 4 yearsWithin 3.5.3, 'Change the destination folder' not supporting due to studio already disabled the change option of destination
-
VIISHRUT MAVANII over 4 years@NuwanWithanage I have another solution & it may help you. try to generate debug signed build first then generate release signed.
-
Divakar Murugesh about 4 yearsThanks & Nice solution. I updated Android Studio even this error occurs in Android Studio 3.6. This solution saved my day. Thanks again
-
Wilmer almost 4 yearsAlso works for
classpath 'com.android.tools.build:gradle:3.5.3'
Android Studio 3.6.3 -
Farid over 3 yearsYou can't generate "Signed debug APK"
-
Dita Aji Pratama over 3 yearsYou can sign your debug build developer.android.com/studio/publish/app-signing#debug-mode
-
Pipin Indrawan about 3 yearsthanks for the solution my app has hundred to thousand c++ class so cleaning will consume time.