Cause: buildOutput.apkData must not be null

后端 未结 28 1457
再見小時候
再見小時候 2020-12-07 12:03

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 err

相关标签:
28条回答
  • 2020-12-07 12:19

    I've tried all solutions and non of them helped! finally after many trying, I figured it out, just follow the tips:

    1. copy your signature keystrok (that you use to release) inside yourProject/app/
    2. gradle.properties (modify values related to your own key):
      MYAPP_RELEASE_STORE_FILE=KEYSTROK_NAME
      MYAPP_RELEASE_KEY_ALIAS=KEY_ALIAS
      MYAPP_RELEASE_STORE_PASSWORD=R_PASS
      MYAPP_RELEASE_KEY_PASSWORD=K_PASS
      android.enableR8=true
      
    3. app level build.gradle (inside android):

      signingConfigs{
          release{
              if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                  storeFile file(MYAPP_RELEASE_STORE_FILE)
                  storePassword MYAPP_RELEASE_STORE_PASSWORD
                  keyAlias MYAPP_RELEASE_KEY_ALIAS
                  keyPassword MYAPP_RELEASE_KEY_PASSWORD
              }
          }
      }
      
      configurations {
          cleanedAnnotations
          compile.exclude group: 'org.jetbrains' , module:'annotations'
      }
      
      
    4. app level build.gradle (inside buildTypes):
      release {
          manifestPlaceholders = [analytics_deactivated: "false"]
          minifyEnabled true
          signingConfig signingConfigs.release
          useProguard true
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
      

      5. finally this command:

    mac: ./gradlew clean assemble_YOUR_FAVOR_Release

    win: gradlew clean assemble_YOUR_FAVOR_Release

    where _YOUR_FAVOR_ is your optional favor, if you are not using any favor, just simply use assembleRelease instead of assemble_YOUR_FAVOR_Release

    0 讨论(0)
  • 2020-12-07 12:19

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

    0 讨论(0)
  • 2020-12-07 12:20

    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

    1. Clean the project
    2. Restart Android Studio + Invalidate Caches
    3. Delete the build, debug, and releases folder
    4. Make project
    5. Generate signed APK

    Reference

    0 讨论(0)
  • 2020-12-07 12:20

    I've tried many things to solve the issue, but nothing helped. I get this error when trying to generate a signed apk.

    Downgrading to older versions of Android Studio helped (3.4.2) worked, however this is not the solution.

    The 'Clean Project' function in AS does not clean the place where your generated apk is created and there is one file that may be blocking the whole procedure: output.json

    Try removing output.json from .../app/projectname/release/output.json

    0 讨论(0)
  • 2020-12-07 12:20

    the only solution that works for me is using in my root gradle

    classpath 'com.android.tools.build:gradle:3.3.0'
    

    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

    0 讨论(0)
  • 2020-12-07 12:20

    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

    0 讨论(0)
提交回复
热议问题