Cause: buildOutput.apkData must not be null

2020-02-02 04:15发布

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)
        ...

27条回答
三岁会撩人
2楼-- · 2020-02-02 04:57

This issue happens after update my Android studio v3.4 to v3.5 Now, it is working fine

I fixed this issue by deleting debug/output.json and release/output.json files

Android Studio 3.5 compilesdkVersion 28

apk generating working

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-02-02 04:58

I was using Android Studio 3.5 beta 2 and I was having the exact same error but only on my release build. After trying every other solution I found, the only way I was able to compile again was to go back to Android Studio 3.4.

查看更多
何必那么认真
4楼-- · 2020-02-02 05:00

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 current destination path is

c:\user\folder\project\app

change it to

c:\user\folder\project

then it will generate the signed apk successfully.

查看更多
再贱就再见
5楼-- · 2020-02-02 05:02

It works for me:

  1. delete build folder from your project manually.

  2. in terminal of android studio type this command

if windows user

gradlew clean build

if linux user

./gradlew clean build
查看更多
手持菜刀,她持情操
6楼-- · 2020-02-02 05:05

Generate Signed APK for debug, and then you can generate signed APK for release.

查看更多
Lonely孤独者°
7楼-- · 2020-02-02 05:06

This issue is happens usually when you are running multiple android studio window with different projects.

The solution is

  • choose project than delete .gradle and build folders
  • than clean and rebuild the project.

please ref screen shot attached

please ref screen shot attached

查看更多
登录 后发表回答