r0adkll / sign-android-release

A GitHub action to sign an APK or AAB
MIT License
362 stars 137 forks source link

Problem signing aap #39

Open mindaugasnakrosis opened 3 years ago

mindaugasnakrosis commented 3 years ago

I get an error in my github actions:

Preparing to sign key @ android/app/build/outputs/bundle/release with signing key /usr/bin/jarsigner -keystore android/app/build/outputs/bundle/release/signingKey.jks -storepass -keypass android/app/build/outputs/bundle/release/app-release.aab *** jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 54105 but got 55476 bytes)

I found this answer:

https://stackoverflow.com/questions/5089042/jarsigner-unable-to-sign-jar-java-util-zip-zipexception-invalid-entry-compres

But it does not make any sense to me. How can it be already signed?

I found related issue: #31

however, it does not say how to solve the issue (at least I did not understand the solution)

My configuration file:

on: workflow_dispatch

name: Release to Google Play Store

jobs:
  beta-distribution:
    runs-on: ubuntu-latest
    name: Beta Distribution
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - uses: actions/setup-node@master
    - uses: c-hive/gha-yarn-cache@v1

    - name: Install node modules
      run: |
        yarn install
    - name: Cache Gradle Wrapper
      uses: actions/cache@v2
      with:
        path: ~/.gradle/wrapper
        key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}

    - name: Cache Gradle Dependencies
      uses: actions/cache@v2
      with:
        path: ~/.gradle/caches
        key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
        restore-keys: |
          ${{ runner.os }}-gradle-caches-
    - name: Make Gradlew Executable
      run: cd android && chmod +x ./gradlew

    - name: Build Android App Bundle
      run: |
        cd android && ./gradlew bundleRelease --no-daemon
    - name: Sign App Bundle
      id: sign_app
      uses: r0adkll/sign-android-release@v1
      with:
        releaseDirectory: android/app/build/outputs/bundle/release
        signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
        alias: ${{ secrets.ANDROID_SIGNING_ALIAS }}
        keyStorePassword: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
        keyPassword: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}

    - name: Upload Artifact
      uses: actions/upload-artifact@v2
      with:
        name: Signed App Bundle
        path: ${{steps.sign_app.outputs.signedReleaseFile}}

    - name: Deploy to Play Store (BETA)
      uses: r0adkll/upload-google-play@v1
      with:
        serviceAccountJsonPlainText: ${{ secrets.ANDROID_SERVICE_ACCOUNT }}
        packageName: com.wmsappbare
        releaseFile: a${{steps.sign_app.outputs.signedReleaseFile}}
        track: beta
        inAppUpdatePriority: 3
        userFraction: 0.5
        whatsNewDirectory: android/release-notes/
        # mappingFile: android/app/build/outputs/mapping/release/mapping.txt

@r0adkll might you give me some leads how to debug this issue?

ArshanKhanifar commented 3 years ago

+1 having the same issue here.

mindaugasnakrosis commented 3 years ago

@ArshanKhanifar posted a stackoverflow question here: https://stackoverflow.com/questions/67604963/unable-to-sign-jar-invalid-entry-compressed-size

ArshanKhanifar commented 3 years ago

I realized my problem was that I was actually building a bundle instead of an APK. So I changed my releaseDirectory to: releaseDirectory: android/app/build/outputs/apk/release and also invoked ./gradlew with assembleRelease.

This fixed it for me. Here is my job file:

      - name: Build Android App Bundle
        run: |
          cd android && ./gradlew assembleRelease --no-daemon

      - name: Sign App Bundle
        id: sign_app
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: android/app/build/outputs/apk/release
          signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
          alias: ${{ secrets.ANDROID_SIGNING_ALIAS }}
          keyStorePassword: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
          keyPassword: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
ArshanKhanifar commented 3 years ago

@mindaugasnakrosis Sorry I don't know about app bundles just yet so don't have anything to add to ur stackoverflow question for now.

I remember when I was making the key, there were two different ways to sign the app: image

Make sure you did this by selecting the Android App Bundle option, not the APK option.

You can access this by: Build > Build Bundle(s) / APK(s) image

atiernan commented 3 years ago

I ran in to this issue, the fix was to remove the signingConfig signingConfigs.debugline from within buildTypes -> release in build.gradle

rsi2m commented 3 years ago

I ran in to this issue, the fix was to remove the signingConfig signingConfigs.debugline from within buildTypes -> release in build.gradle

Yeah, this fix helped me as well! Thanks!

dhavallogistic commented 2 years ago

I ran in to this issue, the fix was to remove the signingConfig signingConfigs.debugline from within buildTypes -> release in build.gradle

Yes worked like Gem