mjaakko / NeoStumbler

New stumbler application for contributing data to geolocation services
MIT License
118 stars 10 forks source link

Build issues #275

Open IzzySoft opened 4 days ago

IzzySoft commented 4 days ago

I've tried building the fdroid flavor from source but failed, as it seemingly insists on signing the APK but fails. Recipe:

          - keytool -genkey -v -keystore keystore.jks -alias dummy -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -validity 10000 -dname "cn=dummy" -storepass storepass -keypass keypass
          - export SIGNING_STORE_PASSWORD=storepass SIGNING_KEY_ALIAS=dummy SIGNING_KEY_PASSWORD=keypass
          - ./gradlew assembleFdroidRelease

Build error:

> Task :app:packageFdroidRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageFdroidRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > com.android.ide.common.signing.KeytoolException: Failed to read key dummy from store "/build/repo/keystore.jks": Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

Even if I remove the signing call using sed -r '/signingConfig.release/d' -i app/build.gradle, same result. If I instead use ./gradlew buildFdroidRelease, as the Readme says, I don't get any APK.

Can you please explain how to build an unsigned APK of the fdroid flavor? The hint from the Readme seems not to produce it.

mjaakko commented 4 days ago

Signing the APK fails in your example, because the password for the keystore and the key are different: https://developer.android.com/studio/known-issues#ki-key-keystore-warning

mjaakko commented 3 days ago

But yeah, the README is not up-to-date with this. I'll look into it

IzzySoft commented 3 days ago

Would be great if signing could be skipped altogether. I'd need an unsigned APK anyway. But are you saying passwords for store and key must be identical (then why separate variables for them)? The error message at the place you've linked to is different. But OK, I can give that a try, though I'd be surprised… Oh: surprise! WTF…

Holy crap, a second surprise: it's even reproducible!

    "upstream_signed_apk_sha256": "0f349ab94afa1e9eea1253d95fb94dab669e647e146c3e634cfb8e92a399b36f",
    "built_unsigned_apk_sha256": "f16322056e8b754caf071fa024dbf5208e59b7ac572f8adcede5bbf59d1bb8f6",
    "signature_copied_apk_sha256": "0f349ab94afa1e9eea1253d95fb94dab669e647e146c3e634cfb8e92a399b36f"

(the hashes match) NIIICE!

image

(source)

Green shield is up already in the IzzyOnDroid repo. Thanks a lot for your help!

PS: I leave this issue open as reminder for the Readme update. Feel free to close – my problem was solved :star_struck:

obfusk commented 3 days ago

https://github.com/mjaakko/NeoStumbler/blob/dc83497e52c752af97fe1387765a9431e4831017/app/build.gradle#L55

The reason it failed is because sed -r '/signingConfig.release/d' -i app/build.gradle is wrong; it should be sed -r '/signingConfigs.release/d' -i app/build.gradle (note the "s" before the ".").

IzzySoft commented 3 days ago

Fixed, thanks!