Cause: buildOutput.apkData must not be null

后端 未结 28 1652
再見小時候
再見小時候 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

提交回复
热议问题