Gradle zipAlign task not working?

后端 未结 2 1904
死守一世寂寞
死守一世寂寞 2020-12-09 10:53

It appears the Gradle zipAlign task isn\'t working for me, not sure what I\'m doing wrong. I\'ve tried including the zipAlign task, and not including it, but it doesn\'t see

相关标签:
2条回答
  • 2020-12-09 11:25

    Your release build type is not configured for signing.

    If you are signing your apk manually, you need to run ZipAlign manually as well. ZipAlign must happen after signing.

    Gradle will zipalign an apk only if it can sign as well.

    To setup signing for the release config, you'll need to first create a new signing config, then assign it to the build type.

    android {
      signingConfigs {
        release {
          storeFile file("/path/to/keystore")
          storePassword "??"
          keyAlias "??"
          keyPassword "??"
        }
      }
    
      buildTypes {
        release {
          signingConfig signingConfigs.release
        }
      }
    }
    

    Note that all 4 parameters in the signing config are required, otherwise it'll consider some values are missing and it won't even attempt to sign.

    0 讨论(0)
  • 2020-12-09 11:38

    It is possible to take any existing Android Studio gradle project and build/sign it from the command line without editing any files. This makes it very nice for storing your project in version control while keeping your keys and passwords separate and not in your build.gradle file:

    ./gradlew assembleRelease -Pandroid.injected.signing.store.file=$KEYFILE -Pandroid.injected.signing.store.password=$STORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEY_ALIAS -Pandroid.injected.signing.key.password=$KEY_PASSWORD
    
    0 讨论(0)
提交回复
热议问题