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条回答
We Are One
2楼-- · 2020-02-02 05:10

Cleaning the project didn't help me but manually deleting all the auto-generated build folders in all modules helped. enter image description here

查看更多
啃猪蹄的小仙女
3楼-- · 2020-02-02 05:12

The solution for me was to delete all files and folders from the apk output folder. I had this problem when creating a signed apk for a "production" flavor and the output.json in the "feature" output folder causes the problem -> Android Studio 3.6 Canary 7 showed me the correct error message. It is also working now for AS 3.5 stable with Gradle Plugin 3.5.0.

查看更多
唯我独甜
4楼-- · 2020-02-02 05:14

Manually delete all the exiting build variant folder as well build folder in project folder worked for me.

查看更多
登录 后发表回答