kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.33k stars 1.84k forks source link

p4a signing doesn't work for python 3 app - my mistake or a bug? #1350

Open ghost opened 6 years ago

ghost commented 6 years ago

I might be doing something wrong, but I ran the following command to attempt to build a signed apk:

p4a apk --keystore /root/keystore.jks --signkey spenkey --keystorepw=<pw removed> --signkeypw=<pw removed> --release --debug --private /my-app/ --orientation user --window --package=org.example.myapp --name "My App" --version 0.6.17 --bootstrap=sdl2 --requirements=python3crystax,python-dateutil,sdl2,pysdl2,<longer list> --arch=armeabi-v7a

The result, however, is a unnamed_dist_1-release-unsigned.apk - so it seems that didn't work.

I even defined P4A_RELEASE_KEYALIAS, P4A_RELEASE_KEYSTORE, P4A_RELEASE_KEYSTORE_PASSWD, P4A_RELEASE_KEYSTORE_PASSWD with the same matching values, and I get the same result.

What am I doing wrong? Is the signing broken? Or is it signed even though unsigned is in the output name?

ghost commented 6 years ago

Fwiw: I still haven't got it to work, but jarsigner works, just in case anyone else has the same issue

inclement commented 6 years ago

I've actually never used p4a's signing arguments - I guess this is something we should add to the unit tests. However, I can't think of any reason offhand that it should be different for python3 vs python2 apps, so (unless you tested it) I guess it's more likely generally broken.

ghost commented 5 years ago

I'll try to keep in the back of my head to look at this at some point in the near future, if alone to get the hack out of my build script :grimacing:

AndreMiras commented 5 years ago

@JonasT I've often signed APK and it did work OK, for instance there https://github.com/AndreMiras/QrScan/releases/tag/v20190303 However I'm doing it through buildozer so I haven't checked p4a params. If this is still an issue for you I can take a deeper look at what args are being used. If the issue is gone, please close :smiley:

ghost commented 5 years ago

@AndreMiras sorry I was temporarily stuck with the Cython type inference crash :smile: I promise I'll rerun this with p4a's signing in 1-2 days and see what comes up, whether it works or what happens. I mean when I made this ticket I had no clue of what is going on anyway so it might be easy to fix for myself now, I just haven't looked into it yet

JohnBuckleyGitHub commented 5 years ago

I have not been successful with using P4A to sign .apk's with Python 3. I am setting the environment variables: 'P4A_RELEASE_KEYSTORE' 'P4A_RELEASE_KEYSTORE_PASSWD' 'P4A_RELEASE_KEYALIAS_PASSWD 'P4A_RELEASE_KEYALIAS'

then using the command line: p4a apk --release --version=2.4.0 --dist_name=vsbike --bootstrap sdl2 --requirements=android,python3==3.7,kivy,plyer,numpy,boto3,botocore,urllib3,python-dateutil,jmespath,s3transfer --arch armeabi-v7a --name VSbike --package com.velosense.bikeano --android_api=28 --permission WRITE_EXTERNAL_STORAGE --permission ACCESS_FINE_LOCATION --permission INTERNET --permission ACCESS_NETWORK_STATE --add-jar android_antlib-restricted_4-15-0.jar --add-jar channel.jar --orientation portrait --wakelock --window --color=always --private .

As a note, there is not any mention that replacing debug with release will give a release version, but it does finish with an apk that says unsigned. As JonasT mentioned, jarsigner will then sign it.

ghost commented 5 years ago

Okay, thanks to changes in my setup.py pull request I should be able to go back to the p4a built-in signing and look at this. @johnbolia thanks for confirming this, and for poking it to make me take a look :smile: I have been delaying this for a while