Building with API 27 following the "do with 19 then 27" thing

365 views
Skip to first unread message

Thomas S.

unread,
Oct 1, 2018, 2:24:22 PM10/1/18
to Kivy users support
Hello, 

I've been trying to update my app and unfortunately I stumbled upon a few problems on the way. Please, bare with me I will try to make this fast and precise.

So I am using Buildozer 0.34 on Ubuntu 16.04 installed per the instructions found at buildozer readthedocs. Requirements are kivy (it's kivy 1.10.0 being built), requests and lxml. All recipes build fine with api = 19, sdk=23,  min.api = 19, ndk=16b (downloaded) set in buildozer.spec file. With this setup I get a working app on my device (Android 7).

Then, for the upgrade: I delete my dists folder and change api version to 27. When it gets to the [DEBUG] phase I get this:

[INFO]:    Selecting java build tool:
[INFO]:    Detected highest available build tools version to be 28.0.3
[INFO]:        Building with gradle, as gradle executable is present
[DEBUG]:   -> running gradlew assembleDebug
[DEBUG]:    Starting a Gradle Daemon (subsequent builds will be faster)
[DEBUG]:    > Configuring > 0/1 projects > root project > Compiling /media/uIncremental java compilation is an incubating feature.
[DEBUG]:    > Configuring > 1/1 projects > Resolving dependencies ':_debugUn:preBuild UP-TO-DATE
[DEBUG]:    :preDebugBuild UP-TO-DATE
[DEBUG]:    :checkDebugManifest
[DEBUG]:    :prepareDebugDependencies
[DEBUG]:    :compileDebugAidl
[DEBUG]:    :compileDebugRenderscript
[DEBUG]:    :generateDebugBuildConfig
[DEBUG]:    :generateDebugResValues
[DEBUG]:    :generateDebugResources
[DEBUG]:    :mergeDebugResources
[DEBUG]:    :processDebugManifest
[DEBUG]:    :processDebugResources
[DEBUG]:    :generateDebugSources
[DEBUG]:    :incrementalDebugJavaCompilationSafeguard
[DEBUG]:    :javaPreCompileDebug
[DEBUG]:    :compileDebugJavaWithJavac
[DEBUG]:    :compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
[DEBUG]:    /media/ubuntu/usbdata/ELSBuilding/.buildozer/android/platform/build/dists/euroleaguestats/src/main/java/org/kivy/android/PythonService.java:97: error: cannot find symbol
[DEBUG]:            notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
[DEBUG]:                        ^
[DEBUG]:      symbol:   method setLatestEventInfo(Context,String,String,PendingIntent)
[DEBUG]:      location: variable notification of type Notification
[DEBUG]:    Note: Some input files use or override a deprecated API.
[DEBUG]:    Note: Recompile with -Xlint:deprecation for details.
[DEBUG]:    1 error
[DEBUG]:    :compileDebugJavaWithJavac FAILED
[DEBUG]:   
[DEBUG]:    FAILURE: Build failed with an exception.
[DEBUG]:   
[DEBUG]:    * What went wrong:
[DEBUG]:    Execution failed for task ':compileDebugJavaWithJavac'.
[DEBUG]:    > Compilation failed; see the compiler error output for details.
[DEBUG]:   
[DEBUG]:    * Try:
[DEBUG]:    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[DEBUG]:   
[DEBUG]:    BUILD FAILED
[DEBUG]:   
[DEBUG]:    Total time: 1 mins 17.225 secs
Exception in thread background thread for pid 7951:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/sh.py", line 2170, in background_thread
    handle_exit_code(exit_code)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/sh.py", line 1929, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/sh.py", line 672, in handle_command_exit_code
    raise exc
ErrorReturnCode_1: 

  RAN: ./gradlew assembleDebug

  STDOUT:
Starting a Gradle Daemon (subsequent builds will be faster)
Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:incrementalDebugJavaCompilationSafeguard
:javaPreCompileDebug
:compileDebugJavaWithJavac
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/media/ubuntu/usbdata/ELSBuilding/.buildozer/android/platform/build/dists/euroleaguestats/src/main/java/org/kivy/android/PythonService.java:97: error: cannot find symbol
        notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
                    ^
  symbol:   method setLatestEventInfo(Context,String,String,PendingIntent)
  location: variable notification of type Notification
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 17.225 secs


  STDERR:


[DEBUG]:   
[INFO]:    STDOUT (last 20 lines of 42):
  symbol:   method setLatestEventInfo(Context,String,String,PendingIntent)
  location: variable notification of type Notification
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 17.225 secs

[INFO]:    STDERR:
[INFO]:    COMMAND:
cd /media/ubuntu/usbdata/ELSBuilding/.buildozer/android/platform/build/dists/euroleaguestats && ./gradlew assembleDebug



The java version is openjdk-8.

ZenCODE

unread,
Oct 1, 2018, 3:04:07 PM10/1/18
to Kivy users support
Hmm. I'm hitting issue which I think may be related. There are too many variables for me to really say what broke, and I'm hitting my head on that now.

Using a very similar setup (API 27, ndk16b, Ubuntu 16.04, sdk 28, the APK builds and runs, but there is no android module even through it's in the requirement ("import failed, not module named android") and although I can start the python android service, it dies immediately on the first import. This crash happens even if the error is trapped.

Your error on the PythonService makes me think these are related. Has anyone got the android module working using API 26+? The python-for-android service? I suspect these are currently broken, but as I'm also switching from the android_old toolchain, which changed a few things, so I can't be certain what the cause is. Perhaps others can share their findings?

Are you using an android service iun your app? If you take this out, does it build?

ZenCODE

unread,
Oct 1, 2018, 3:14:17 PM10/1/18
to Kivy users support

Thomas Sfondylis

unread,
Oct 1, 2018, 4:32:41 PM10/1/18
to kivy-...@googlegroups.com
@ZenCODE

I am not using any android service in my app nor I have defined any classes of this kind.

I have been following github ticket 1219 and posts from rnixx. I made the changes he proposed, changing java source and target to 1.7. I also followed the instructions for setting_app_platform_19. 

The only thing I did not do the same way as rnixx is to provide the path for ndk 16b the way he did (does it really matter?) 

The error persists. I am using the stable version for p4a, should I try master?

Conclusion: either these instructions do not apply in my case or i am doing something wrong. As I said, I have already tried rnixx's suggestions.

I will try again tomorrow though. I have to.

Did you have any luck?

Regards, Thomas.

Thomas S.

unread,
Oct 2, 2018, 7:08:08 PM10/2/18
to Kivy users support
Right. It seems that Google Play has accepted my signed apk archive!!! It recognizes the correct api version (27) and throws no errors whatsoever.

Things that I tried: The error that I mentioned above (compileDebugJavaWithJavac FAILED ) seems that can be caught and logged as an error without further consequences for the building procedure. I tried to insert a few lines of code in the PythonService.java file to this effect but my effort was not successful. Next, I changed the p4a.branch in buildozer.spec file to master. As I am using a recipe for building lxml module the building failed because the recipe calls the CompiledComponentsPythonRecipe Class from toolchain.py unless I add:
                                                     from pythonforandroid.recipe import Recipe, CompiledComponentsPythonRecipe

Then, I built the app targeting api 19 and deleted the dists folder upon completion. Finally, I rebuilt the app targeting api 27, no errors this time, BUILD SUCCESSFUL.

However, I do not understand the reasons why I succeeded this time.

[INFO]:    Selecting java build tool:
[INFO]:    Detected highest available build tools version to be 28.0.3
[INFO]:        Building with gradle, as gradle executable is present
[DEBUG]:   -> running gradlew assembleDebug
[DEBUG]:       > Configuring > 0/1 projects > root project > Compiling /media/uIncremental java compilation is an incubating feature.
[DEBUG]:       :preBuild UP-TO-DATE
[DEBUG]:       :preDebugBuild UP-TO-DATE
[DEBUG]:       :checkDebugManifest
[DEBUG]:       :prepareDebugDependencies
[DEBUG]:       :compileDebugAidl
[DEBUG]:       :compileDebugRenderscript
[DEBUG]:       :generateDebugBuildConfig
[DEBUG]:       :generateDebugResValues
[DEBUG]:       :generateDebugResources
[DEBUG]:       :mergeDebugResources
[DEBUG]:       :processDebugManifest
[DEBUG]:       :processDebugResources
[DEBUG]:       :generateDebugSources
[DEBUG]:       :incrementalDebugJavaCompilationSafeguard
[DEBUG]:       :javaPreCompileDebug
[DEBUG]:       :compileDebugJavaWithJavac
[DEBUG]:       :compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
[DEBUG]:       Note: Some input files use or override a deprecated API.

[DEBUG]:       Note: Recompile with -Xlint:deprecation for details.
[DEBUG]:       :compileDebugNdk UP-TO-DATE
[DEBUG]:       :compileDebugSources
[DEBUG]:       :mergeDebugShaders
[DEBUG]:       :compileDebugShaders
[DEBUG]:       :generateDebugAssets
[DEBUG]:       :mergeDebugAssets
[DEBUG]:       :transformClassesWithDexForDebug
[DEBUG]:      
[DEBUG]:       Running dex as a separate process.
[DEBUG]:      
[DEBUG]:       To run dex in process, the Gradle daemon needs a larger heap.
[DEBUG]:       It currently has 1024 MB.
[DEBUG]:       For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
[DEBUG]:       To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
[DEBUG]:       For more information see https://docs.gradle.org/current/userguide/build_environment.html
[DEBUG]:      
[DEBUG]:       :mergeDebugJniLibFolders
[DEBUG]:       :transformNativeLibsWithMergeJniLibsForDebug
[DEBUG]:       > Building 80% > :transformNativeLibsWithStripDebugSymbolForDebu:transformNativeLibsWithStripDebugSymbolForDebug
[DEBUG]:       :processDebugJavaRes UP-TO-DATE
[DEBUG]:       :transformResourcesWithMergeJavaResForDebug
[DEBUG]:       :validateSigningDebug
[DEBUG]:       :packageDebug
[DEBUG]:       :assembleDebug
[DEBUG]:      
[DEBUG]:       BUILD SUCCESSFUL
[DEBUG]:      
[DEBUG]:       Total time: 30.231 secs

Erwann Lebrun

unread,
Oct 2, 2018, 7:49:25 PM10/2/18
to Kivy users support
Hi Thomas,

Could you please tell me how you signed your APK?
I can finally produce a API27 APK but somehow get an error when I try to sign it...

Cheers
Message has been deleted
Message has been deleted
Message has been deleted

Thomas S.

unread,
Oct 3, 2018, 12:18:07 PM10/3/18
to Kivy users support
@Erwann

As far as signing the app is concerned I followed the instructions here. Just scroll down to the "Sign your app from command line" section.

Assuming you have generated a key, you then export some variables like so:

export P4A_RELEASE_KEYSTORE=~/keystores/<your-new-key>.keystore
export P4A_RELEASE_KEYSTORE_PASSWD=android
export P4A_RELEASE_KEYALIAS_PASSWD=android
export P4A_RELEASE_KEYALIAS=<your-key-alias>

Then: buildozer -v android release

I built my app using SDK 23 and build-tools 28.0.3. I placed the .keystore file in the .buildozer/.../bin directory and following step 2 from link above, I run:

~/.buildozer/android/platform/android-sdk-23/build-tools/28.0.3/zipalign -v 4 myapp-release.apk myapp-release-optimized.apk

and

finally according to step 3 I run:

~/.buildozer/android/platform/android-sdk-23/build-tools/28.0.3/apksigner sign --ks myappname.keystore --out MyApp.apk myapp-release-optimized.apk

where I had to enter the key.

The above worked for me.

Hopefully, the instructions will get you and/or someone else sorted out.

Regards,
Thomas

Thomas S.

unread,
Oct 3, 2018, 12:33:38 PM10/3/18
to Kivy users support
export P4A_RELEASE_KEYSTORE_PASSWD=android
export P4A_RELEASE_KEYALIAS_PASSWD=android

android = <your key>

Erwann Lebrun

unread,
Oct 6, 2018, 12:54:41 AM10/6/18
to Kivy users support
Thanks Thomas,

As replied on the other post, I somehow still managed to get my app live without going through the zipalign step... strange but oh well, it worked for me!
Thank you anyway for your precision, I still want to work on other apps and they will come in handy!!!!
It is thanks to people like you that people like me (who have barely any clue about how to code) can still manage to create apps so thank you and thank you ZenCODE!!!

Erwann

ZenCODE

unread,
Oct 6, 2018, 3:00:56 AM10/6/18
to Kivy users support
My pleasure. Very glad you got it all working...:-)
Reply all
Reply to author
Forward
0 new messages