Python-for-android: Google requiring API Target 26 in Aug/Nov 2018

Created on 10 Jan 2018  ·  138Comments  ·  Source: kivy/python-for-android

Just wanted to put it on the devs’ radar. We’ve been limited to 19 for the last couple years, afaik, but kivy will need to support targeting 26 for new apps starting in August, and for app updates starting in November: https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html?m=1

If there’s currently a straightforward way to target 21 or higher then I’ll stand corrected and be very interested in hearing how.

Most helpful comment

@atnccetti. Thanks. There are a few issues around python services and pyjnius that I want to resolve before redoing the VM. When I get there, I'll definitely look at this. Thanks :-)

All 138 comments

Looking into this now, when setting target API as as 26, it tries to download:

    Downloading http://dl.google.com/android/android-sdk_r26-linux.tgz

which fails as this file does not exist. The one below does, so that's why it works with sdk 23.

   Downloading http://dl.google.com/android/android-sdk_r23-linux.tgz

So google have altered the path of the downloads? It also appears they have changed the location of some files and deprecated the "./android" command which now says you should use the "bin/sdkmanager" tool instead to install sdk's. But I can't find any mention of where they have moved the sdks for downloading. It seems "buildozer/target/android.py " file would need to be changed to use these need tools?

Google post mentioned at the beginning of this discussion reads:

In order to provide users with the best Android experience possible, the Google Play Console will require that apps target a recent API level:

  • August 2018: New apps required to target API level 26 (Android 8.0) or higher.
  • November 2018: Updates to existing apps required to target API level 26 or higher.
  • 2019 onwards: Each year the targetSdkVersion requirement will advance. Within one year following each Android dessert release, new apps and app updates will need to target the corresponding API level or higher.

Existing apps that are not receiving updates are unaffected. Developers remain free to use a minSdkVersion of their choice, so there is no change to your ability to build apps for older Android versions. We encourage developers to provide backwards compatibility as far as reasonably possible. Future Android versions will also restrict apps that don't target a recent API level and adversely impact performance or security.

Current p4a documentation says ndk r7, SDK 14 - this is years behind current versions. I've tried to build app with SDK=26 and NDK 15c but it has failed. API 27 requires NDK 16, since its platform is not supported in 15c. I haven't tried to use it but I presume it will fail. I've notices p4a uses gcc, gcc was deprecated in NDK r11 and replaced by Clang. Android development team retired ant form SDK a year ago (see https://stackoverflow.com/questions/42912824/the-ant-folder-is-suddenly-missing-from-android-sdk-did-google-remove-it). P4a adopted gradle only last summer. It looks there is plenty to be done and not much time left to catch up. Fortunately Google made revamp easier: it only makes sense to use latest SDK/NdK while building and Android app...

This seems to be the biggest issue facing Kivy (at least for Android devs). Is there some hope that there will be a re-vamp to support SDK 26+? In August, just 3 months away, no one will be able to create a new Kivy app for Android, and in November, any existing apps will be stuck as-is until/unless this is addressed. I need to figure out what I'm doing for current and in-development apps asap. Do we need a bounty?

Unless someone steps in to do the work (which would be welcome, and I can give some guidance), this is waiting on me having some serious time to work on p4a. I hope to get to it soon enough, but I'm not going to make any guarantees right now.

Edit: The hard part as far as I'm concerned is moving to clang. This probably shouldn't actually be a big issue, but I think it's the most unknown quantity involved.

@inclement. I would be happy to help out here, but it's not an area I am familiar with. I was going to take the following approach:

a. Get a VM building against API 27 on an 18.04 Mate Ubuntu OS using AndroidStudio for the SDK installation.
b. Once that is working, clean up, snapshot that and make it publically available for those who need it.
c. Dig into the the python-for-android and buildozer parts that need to automate this process

I think it's urgent to get a working build VM so the deadline is not a do-or-die. The full solution can then follow in time?

edit: I should probably try as use the commandline tools to install the sdk's, as we will probably need to use those via buildozer for the final solution?

Sounds great to me!
On Fri, May 11, 2018 at 5:31 AM Richard Larkin notifications@github.com
wrote:

@inclement https://github.com/inclement. I would be happy to help out
here, but it's not an area I am familiar with. I was going to take the
following approach:

a. Get a VM building against API 27 on an 18.04 Mate Ubuntu OS using
AndroidStudio for the SDK installation.
b. Once that is working, clean up, snapshot that and make it publically
available for those who need it.
c. Dig into the the python-for-android and buildozer parts that need to
automate this process

I think it's urgent to get a working build VM so the deadline is not a
do-or-die. The full solution can then follow in time?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-388349993,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKTLxybbp6nWO0_nTmyvmsk1o0HArVaLks5txYScgaJpZM4RZ5U5
.

From my point of view, this issue is not with creating a VM but with changing p4a's code to support the latest NDK and SDK. The important steps (which can be done semi-independently) are:

1) Make sure p4a works with API 27, using an up to date Android SDK. I haven't tried this at all, but it shouldn't be too hard, even if it requires a few small changes.

2) Make p4a work with the current NDK. This means making it use clang instead of gcc, as gcc is no longer available. I think this is already working with jni recipes (like sdl2), but the other recipe types use gcc explicitly. In principle this shouldn't be too hard, the process for switching to clang is fairly clear (I've tried it briefly before), but messing with the compiler toolchain inevitably brings up issues to fix and I can't predict how much work will be needed. It could also be possible that using clang would have bigger problems to solve but I hopefully not.

Yes, the VM is my thing for a few reasons. I wanted to (a) check building works on 18.04, (b) be able to experiment with safe snapshots and (c) be able to distribute a working build VM.

But that need not concern you. I will post here when I hit issues and need your assistance. If you need to make changes to p4a, you could perhaps do that on a branch that I can pull and test on. I can also push there with any changes I need to make. I will try with sdk = 27 in the buildozer.spec. You mention a different NDK? What should that be?

Lastly,with regards to gcc vs. clang, don't know much but am willing to learn if you can point me to some docs on changes that will need to be made, which version I need to install etc.

I may need a bit of baby sitting getting started, but will document my learning so this whole process is a bit less "black box" like. I think many people would like to help, but it's not at all obvious how to on a project this size. And it's a bit daunting getting started when no docs exists. I know you do tons, and would like to help relieve you, but how to do that is the question...:-)

You mention a different NDK? What should that be?

I just mean the latest NDK release from https://developer.android.com/ndk/downloads/ , currently r17. The main change is likely to be the need to move to clang, I don't expect anything else in particular to break.

Lastly,with regards to gcc vs. clang, don't know much but am willing to learn if you can point me to some docs on changes that will need to be made, which version I need to install etc.

On p4a's side, it currently chooses a gcc toolchain to use, and uses the path to that later in the build process. It does this here. I think this needs to be changed to look for the clang toolchain instead.

Beyond that, I would basically proceed by trying to change it and seeing what breaks. I don't have a deep idea about what will need doing. There is some clang documentation at https://developer.android.com/ndk/guides/standalone_toolchain#working_with_clang , and I've found before that since many projects have had to make the same change there are plenty of questions already asked online about the problems that come up.

Just to note, while this does need doing, NDK r16 should actually work currently using gcc. I don't think this is going to break in the near future, unlike targeting older apis, although moving to clang is obviously still important.

Okay, so I've got the API-27 SDK installed and unzipped the latest NDK. Working from buildozer master.

# Android SDK found at /home/kivy/Android/Sdk
# Android NDK found at /home/kivy/Android/android-ndk-r16b

When I run 'buidozer android debug', I get.
https://gist.github.com/Zen-CODE/9f982e93f437276b9968e1160061a26f

I am using the default-jre/default-jdk with ubuntu 18.04, which seems to be Java 11. Should I be using another java version? Or how to fix?

This error results from using a recent SDK with older versions of python-for-android, but it should be okay if you use p4a master. Did you set the p4a.branch = master option in buildozer.spec? (I think that's the right option name, it should already be there but commented out and set to the default value of stable).

Okay, I have done a git clone of https://github.xom/kivy/python-for-android into /home/kivy/Repos. So the clone lies in /home/kivy/Repos/python-for-android.
In the buildozer.spec file, I have set

p4a.source_dir = /home/kivy/Repos/python-for-android

and I get

# Apache ANT found at /home/kivy/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/kivy/Android/Sdk
# Android NDK found at /home/kivy/Android/android-ndk-r16b
# Run '/home/kivy/Android/Sdk/tools/android list sdk -u -e'
# Cwd /home/kivy/.buildozer/android/platform
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
"android" SDK commands can be translated to sdkmanager commands on a best-effort basis.
Continue? (This prompt can be suppressed with the --use-sdk-wrapper command-line argument
or by setting the USE_SDK_WRAPPER environment variable) [y/N]: y
Running /home/kivy/Android/Sdk/tools/bin/sdkmanager --list --verbose

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 5 more
# Command failed: /home/kivy/Android/Sdk/tools/android list sdk -u -e
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
kivy@kivy-VirtualBox:~/Repos/kivy/examples/demo/touchtracer$ 

edit: master is definitely checked out in the python-for-android clone.

Ah, my mistake, the actual issue is that buildozer itself is not compatible with newer SDKs. It's still good that you're set up with p4a master, your clone method is what I'd recommend for working on this, but it isn't the immediate problem

The issue is that, as outlined by the message, newer SDKs replaced the android binary with sdkmanager. That means buildozer's attempt to query the sdk list here needs to be changed to use sdkmanager, or ideally to use sdkmanager or android depending on what's available.

The correct command is something like sdkmanager --list, as has automatically been guessed in your log, but in that case it looks like some java error has occurred. Does running /home/kivy/Android/Sdk/tools/bin/sdkmanager --list --verbose work if you do it directly?

Running "./android list sdk" gives the same error as does the sdkmanager. So I downgraded to openjdk-8 and it sorted that issue. Now I get a venv issue?

https://gist.github.com/Zen-CODE/d2210ec72984eebd48f286d9fc96b315

Do you have virtualenv installed?

kivy@kivy-VirtualBox:~/Repos/kivy/examples/demo/touchtracer$ pip install virtualenv
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-16.0.0

But still get same error.

Is the virtualenv executable in your $PATH, so you get some answer from which virtualenv? That's the method p4a uses to find it, I'm not sure what would cause it to not work here.

Okay, progress. I now get

Error compiling Cython file:
------------------------------------------------------------
...
    cdef:
        bcm.DISPMANX_UPDATE_HANDLE_T hdl
        bcm.UpdateHandle U
    hdl = bcm.vc_dispmanx_update_start( priority )
    if hdl == 0:
        raise bcm.BCMDisplayException("Couldn't open handle to update-start")
                ^
------------------------------------------------------------

kivy/lib/vidcore_lite/egl.pyx:619:17: cimported module has no attribute 'BCMDisplayException'


  STDERR:

# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Repos/kivy/examples/demo/touchtracer/.buildozer/android/platform/build
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

Which I think is a cython version issue. Will downgrade cython and try again....

Rather than downgrading cython, could you make sure you're using kivy master? You can set kivy==master in the requirements, as normal.

Still get the same error. It did pull master now. cython version is 28.3. Perhaps a clean or distclean?

Might be worth it. I do recognise this error as a cython problem that was fixed at some point, so some cython version should definitely work.

clean fixed that. Now getting to java errors?
https://gist.github.com/Zen-CODE/36db7280eba0d98207241b10c18f10d4

Ah, this is good, it looks like the build is almost completed at the point it fails.

This error is new to me, though. It looks like some kind of ssl problem when downloading gradle. Do you get the same message (without the p4a stuff) if you navigate to home/kivy/Repos/kivy/examples/demo/touchtracer/.buildozer/android/platform/build/dists/myapp/ and run ./gradlew assembleDebug?

Oh, nice find, I've never seen anything like it before.

Built!!! :-)

# Android packaging done!
# APK myapp-0.1-debug.apk available in the bin directory

Will test shortly

Thanks for working on this guys! Hopefully there's a recap or updated build
process down the line, but I'm really looking forward to upgrading my apps
to the latest sdks. I haven't had to deal with runtime permissions requests
on Android yet, but I'm guessing we'll need to update (for instance) the
plyer gps for android to handle this permission request like it already
does on iOS :-P

On Fri, May 18, 2018 at 3:07 PM Richard Larkin notifications@github.com
wrote:

Built!!! :-)

Android packaging done!

APK myapp-0.1-debug.apk available in the bin directory

Will test shortly


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-390345284,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKTLx5AJSEuhWzSt0Dm_ZjMVaDHrn1RQks5tz0YXgaJpZM4RZ5U5
.

The APK installs but the app crashes. Will launch with buildozer and post the logs....
@gorgonaut04. My pleasure. I see my submission to the iStore today also warned that we need to build using the iOS 11 SDK. It all keeps moving! :-)

We identified one or more issues with a recent delivery for your app, "CAMI-Apps". Your delivery was successful, but you may wish to correct the following issues in your next delivery:
SDK Version Issue - In July 2018, iOS app updates submitted to the App Store will need to be built with the iOS '11.0' SDK or later, included in Xcode [9.0] or later. Make sure to update Xcode for future app deliveries.

Looks like the SDL compile/loading is faililng.

V/pythonutil( 3869): Checking pattern libcrypto.*\.so against libSDL2_image.so
V/pythonutil( 3869): Loading library: SDL2
D/dalvikvm( 3869): Trying to load lib /data/app-lib/org.test.myapp-2/libSDL2.so 0x4351f520
D/houdini ( 3869): [3869] Loading library(version: 3.4.7.44914 RELEASE)... successfully.
D/houdini ( 3869): [3869] Open Native Library /data/app-lib/org.test.myapp-2/libSDL2.so failed.
E/dalvikvm( 3869): dlopen("/data/app-lib/org.test.myapp-2/libSDL2.so") failed: dlopen failed: "/data/app-lib/org.test.myapp-2/libSDL2.so" has unexpected e_machine: 40
V/pythonutil( 3869): Library loading error: dlopen failed: "/data/app-lib/org.test.myapp-2/libSDL2.so" has unexpected e_machine: 40
V/pythonutil( 3869): An UnsatisfiedLinkError occurred loading SDL2
W/System.err( 3869): dlopen failed: "/data/app-lib/org.test.myapp-2/libSDL2.so" has unexpected e_machine: 40
D/dalvikvm( 3869): GC_FOR_ALLOC freed 1652K, 44% free 6805K/11948K, paused 6ms, total 6ms
W/dalvikvm( 3869): No implementation found for native Lorg/libsdl/app/SDLActivity;.nativeSetEnv:(Ljava/lang/String;Ljava/lang/String;)V
D/AndroidRuntime( 3869): Shutting down VM
W/dalvikvm( 3869): threadid=1: thread exiting with uncaught exception (group=0x42f05500)
E/AndroidRuntime( 3869): FATAL EXCEPTION: main

Edit: This is part of the output. Please say if you need more. The splash screen displays, they then "The application has stopped working" message dispalys.

Are you running on an x86 device or emulator? I think the e-machine thing means libSDL2.so is compiled for arm but that this doesn't match your device architecture.

An atom based tablet but libhoudini takes care of that. Our current apk
runs on this device no probs. I will test on an ARM device though and post
those logs too...

On Sun, 20 May 2018, 16:33 Alexander Taylor notifications@github.com
wrote:

Are you running on an x86 device or emulator? I think the e-machine thing
means libSDL2.so is compiled for arm but that this doesn't match your
device architecture.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-390487111,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADYDK63HhluwjWbUhKewOVFpo2x_1FlHks5t0X6ngaJpZM4RZ5U5
.

On a Mecer ARM

V/pythonutil( 4416): Checking pattern libcrypto.*\.so against libSDL2_image.so
V/pythonutil( 4416): Loading library: SDL2
D/dalvikvm( 4416): Trying to load lib /data/app-lib/org.test.myapp-2/libSDL2.so 0x413ad490
E/dalvikvm( 4416): dlopen("/data/app-lib/org.test.myapp-2/libSDL2.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "srand" referenced by "libSDL2.so"...
V/pythonutil( 4416): Library loading error: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "srand" referenced by "libSDL2.so"...
V/pythonutil( 4416): An UnsatisfiedLinkError occurred loading SDL2
W/System.err( 4416): Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "srand" referenced by "libSDL2.so"...
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/dalvikvm( 4416): GC_FOR_ALLOC freed 2424K (5898), 51% free 3176K/6452K, paused 10ms, total 10ms
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/dalvikvm( 4416): GC_FOR_ALLOC freed 694K (448), 45% free 3594K/6452K, paused 9ms, total 9ms
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
D/skia    ( 4416): Flag is not 10
V/WindowManager(  504): Changing focus from Window{419df058 u0 org.test.myapp/org.kivy.android.PythonActivity} to Window{41c41628 u0 org.test.myapp/org.kivy.android.PythonActivity}
I/WindowManager(  504): Gaining focus: Window{41c41628 u0 org.test.myapp/org.kivy.android.PythonActivity}
W/dalvikvm( 4416): No implementation found for native Lorg/libsdl/app/SDLActivity;.nativeSetEnv:(Ljava/lang/String;Ljava/lang/String;)V
D/AndroidRuntime( 4416): Shutting down VM
W/dalvikvm( 4416): threadid=1: thread exiting with uncaught exception (group=0x410fa9a8)
E/AndroidRuntime( 4416): FATAL EXCEPTION: main

Complete log of "buildozer android debug" after "buildozer distclean" here:
https://gist.github.com/Zen-CODE/ca841508c5c4a48b6c7b864e86c942b9

@inclement. Any suggestions as to what I can look at? Willing to read/learn/try, but not sure where to start?

Just to check I understand where you currently are (I think I misunderstoood the previous post), testing on an arm device gives the No implementation found for native Lorg/libsdl/app/SDLActivity;.nativeSetEnv:(Ljava/lang/String;Ljava/lang/String;)V error?

I don't know what would cause this, I don't think I've seen this error before. Is it with python2 or python3crystax, and if so does using the other one work?

The ARM device fails with the below.

D/dalvikvm( 4416): Trying to load lib /data/app-lib/org.test.myapp-2/libSDL2.so 0x413ad490
E/dalvikvm( 4416): dlopen("/data/app-lib/org.test.myapp-2/libSDL2.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "srand" referenced by "libSDL2.so"...

Complete: https://gist.github.com/Zen-CODE/ca841508c5c4a48b6c7b864e86c942b9

The build is successful, but running fails with that message...

I found some old links suggesting using NDK 10 or higher to fix this, but it looks like you're using r16b, is that correct?

I guess that does suggest it could be an NDK version error, but it's a bit mysterious to me how or why. You could try using the CrystaX NDK just in case, since it's somewhat different to the current Android NDK.

Yes, using r16b. Would I need to use Python3 for the Crystax NDK? I've only been trying using 2.7, but I can setup 3 if you think it's worth it...

No, python 2 is fine. The CrystaX NDK is just a drop-in replacement for
the normal NDK in most circumstances.

On 06/06/18 22:11, Richard Larkin wrote:
>

Yes, using r16b. Would I need to use Python3 for the Crystax NDK? I've
only been trying using 2.7, but I can setup 3 if you think it's worth
it...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-395215167,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABNQm3zifMJGoaLn2CQ6peN0mdAWdGiKks5t6EVvgaJpZM4RZ5U5.

Thanks so much for working on this @Zen-CODE & @inclement ! EDIT: actually I was able to get roll-out started. My fault rookie mistake!

@40four. No worries :-) Are you sure it's not just a warning, and won't actually allow you to submit? What is exact message it gives you?

Yeah my fault, I just didn't know what I was doing in the play console. I hadn't finished some of the other requirements!

@inclement. Looking in the crystax platform folder, it only seems to support up to API 21...

[INFO]:    Using Crystax NDK r16b
[INFO]:    Found virtualenv at /usr/bin/virtualenv
[INFO]:    ccache is missing, the build will not be optimized in the future.
[WARNING]: ndk_platform doesn't exist: /home/kivy/Android/crystax-ndk-10.3.2/platforms/android-27/arch-arm
[INFO]:    Found the following toolchain versions: ['4.9', '5', 'clang3.6', 'clang3.7']
[INFO]:    Picking the latest gcc toolchain, here 5
[ERROR]:   python-for-android cannot continue; aborting
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy==master,crystax --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Repos/kivy/examples/demo/touchtracer/.buildozer/android/platform/build

Update: Fixed the above by copying the android-27 folder from the r16b zip. Running a new build now...

It now builds with crystax and still fails on the SDL2, but with a different error.

https://gist.github.com/Zen-CODE/7ed1bbcb562bfa93ea745ac8c50904e9

06-08 15:16:47.987 24752 24752 V pythonutil: Checking pattern libcrypto.*\.so against libmain.so
06-08 15:16:47.987 24752 24752 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2.so
06-08 15:16:47.988 24752 24752 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_image.so
06-08 15:16:47.988 24752 24752 V pythonutil: Loading library: SDL2
06-08 15:16:47.995 24752 24752 V pythonutil: Library loading error: dlopen failed: cannot locate symbol "__aeabi_memclr8" referenced by "/data/app/org.test.myapp-1/lib/arm/libSDL2.so"...
06-08 15:16:47.995 24752 24752 V pythonutil: An UnsatisfiedLinkError occurred loading SDL2
06-08 15:16:47.995 24752 24752 W System.err: dlopen failed: cannot locate symbol "__aeabi_memclr8" referenced by "/data/app/org.test.myapp-1/lib/arm/libSDL2.so"...
06-08 15:16:47.999 24752 24752 D PhoneWindowEx: Ex2. SystemProperties.get result >> #ff000000

Update: It seems like the building of SDL2 is the cause of both these APK's failing. How can I look more closely at that? Is there a way I can get buildozer to halt when it builds that file? Or tell it only to build libSDL2.so?

Hi guys, TL;DR the whole conversation. But I think I can help for the new SDK part @inclement
In fact I already use a very up to to date SDK with p4a/buildozer and it works OK, see https://github.com/AndreMiras/EtherollApp/blob/v20180531/dockerfiles/Dockerfile-android#L57

Basically I download SDK tools version 3859397 from https://developer.android.com/studio/index.html and call sdkmanager a few time to update and install API.
I have a Makefile here which is pretty straightforward, see https://github.com/AndreMiras/dockerfiles/blob/master/buildozer_android_new/android_sdk.mk

I can convert it to a python to make a buildozer pull request if you guys are interested.
Currently I just symlink it directly to ${HOME}/.buildozer/android/platform/android-sdk-20 and it works like a drop-in replacement with existing buildozer code.
If you're interested then I would split this conversation in a dedicated buildozer ticket and start working from here.

Thanks, will look into that. Sorry for the delay, but currently working on urgent projects. Will get back to this as soon as time allows.

Great news. Just successfully build and run touchtracer using ndk r16b and API 27 for python 2. I've tried so much that I'm not sure exactly what the crucial step was. I suspect it was using the android tool to handle updates and platform tools installations. But can't be 100% sure. Either way, it's a big relief to know API 27 is do-able :-)

Will try python 3 this week...

Great, very nice work!

On 08/07/18 10:08, Richard Larkin wrote:
>

Great news. Just successfully build and run touchtracer using ndk r16b
and API 27 for python 2. I've tried so much that I'm not sure exactly
what the crucial step was. I suspect it was using the android tool to
handle updates and platform tools installations. But can be 100% sure.
Either way, it's a big relied to know API 27 is do-able :-)

Will try python 3 this week...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-403273811,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABNQmyBbDsWAlZi_0Zounql8N_dLB1aHks5uEcwFgaJpZM4RZ5U5.

Okay, so now I'm trying (on 16.04) with Python 3.5.2 using the crystax 10.3.2 NDK and I get the following:

[INFO]:    Prebuilding kivy for armeabi-v7a
[INFO]:    kivy has no prebuild_armeabi_v7a, skipping
[INFO]:    # Building recipes
[INFO]:    Building hostpython3crystax for armeabi-v7a
[INFO]:    Building sdl2_image for armeabi-v7a
[INFO]:    Building sdl2_mixer for armeabi-v7a
[INFO]:    Building sdl2_ttf for armeabi-v7a
[INFO]:    Building python3crystax for armeabi-v7a
[INFO]:    Building sdl2 for armeabi-v7a
[WARNING]: Couldn't find executable for CC. This indicates a problem locating the {} executable in the Android NDK, not that you don't have a normal compiler installed. Exiting.
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=touchtracer --bootstrap=sdl2 --requirements=python3crystax,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Repos/Python3/kivy/examples/demo/touchtracer/.buildozer/android/platform/build

Frikkin yay! Got Python3 building with the CrystaxNDK, API 27. It required me to copy the "platform/android-27" folder from a newer SDK into the Crystax NDK "platform/android-27" folder and that works. Lots of trials and tribulations along the way, but such is the journey of learning.

But to the point. I will now finalise, clean and compact the "Kivy Complete VM", upload it and announce it's availability on the forums. It will be able build Python2 or Python3 APK's with API 19 or 27. I've removed support for other API's as they are not really valuable and quite size-able on disk.

@inclement. Regarding making this work easily with buildozer as is, I think I will need to start from scratch now that I have a better understanding of how stuff fits together and what the end-system looks like. Its (seems) good news we can still use the android 23 SDK as the "android" executable functionality seems to move to "bin/sdkmanager" with later SDK's. That can be addressed in time....

Thanks again for all the great work you have+are doing. Respect.

It required me to copy the "platform/android-27" folder from a newer SDK into the Crystax NDK "platform/android-27" folder and that works.

Nice, a convenient hack!

Its (seems) good news we can still use the android 23 SDK as the "android" executable functionality seems to move to "bin/sdkmanager" with later SDK's.

python-for-android should already work with this, if it doesn't it's a bug rather than a totally missing feature.

Hi Zen-Code,
How did you build apk using ndk r16b and API 27 for python 2?
I can generate the apk but there is always an error in the execution: SDL Error dlopen failed: can not locate simbol "ftello64" referenced by "libpython2.7.so"

Hi

I am about to make a post announcing the release to a VM for building those
APKs and with instructions that might help. I will let you know when that
is done.

Cheers

On Tue, 17 Jul 2018, 00:19 edsonitk, notifications@github.com wrote:

Hi Zen-Code,
How did you build apk using ndk r16b and API 27 for python 2?
I can generate the apk but there is always an error in the execution: SDL
Error dlopen failed: can not locate simbol "ftello64" referenced by "
libpython2.7.so"


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-405399268,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADYDK14i9JRxvMn_wWYJHZjhRfNCPRVtks5uHRGKgaJpZM4RZ5U5
.

Really don't see how that change address the issue of supporting API 26+

Sorry my bad, because of that error BCMDisplayException in the conversation, I did a quick search to see if it was addressing somewhat duplicated issues. Apparently not that one. Thanks for reopening :smile:

@Zen-CODE did you get chance to make a post announcing the release to a VM for building those APKs and with instructions that might help? If so, please can you link to that post here?

It turns out that although the build succeeds, the upload to the store
fails and says the APK is still using API 19. I'm looking into that now and
will post when I know it is working.

Thanks

On Thu, Aug 16, 2018 at 9:10 AM ApplySci notifications@github.com wrote:

@Zen-CODE https://github.com/Zen-CODE did you get chance to make a post
announcing the release to a VM for building those APKs and with
instructions that might help? If so, please can you link to that post here?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-413448278,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADYDK5atBeqW7uTaqXeZVFDSKtpksPXxks5uRRrTgaJpZM4RZ5U5
.

--

Richard Larkin

The Zen of Kivy: Open Source, cross platform, full stack. Mobile and
desktop.
http://kivy.org/

http://www.camiweb.com/zenkey

huh. how frustrating for you. Thanks for the update, and good luck with getting this sorted!

By the various tests that I did, it seems that the maximum api accepts is 22. Regardless of the SDK and NDK version. Above api 22 creates apk but error occurs on app load: symbol ftello64 referenced by libpython2.7.so

Setup: kivy == 1.10.1 or master, python 2.7, cython == 0.21 or greater, buildozer 0.34 or Dev, p4a == master or stable.
NDK 16b, SDK (20,23,24,25,27)

I trust in God that you can, I really like kivy

What Google actually checks is the targetSdkVersion which is basically independent of the compileSdkVersion, and you can just set it to anything.
It's specified here:
https://github.com/kivy/python-for-android/blob/275d2360840b73cb968d2f8a9e7c833c9d2ca4fd/pythonforandroid/bootstraps/sdl2/build/templates/build.tmpl.gradle#L27

However, the caveat is that if you set it to higher than compileSdkVersion, then the OS will expect your APK to be able to handle things that you might not even have the API handles for.
For example, runtime permissions were introduced in sdk 23. If you set targetSdkVersion to >=23, then Android will expect it to handle runtime permission dialogs, but if you compiled the apk with an older SDK version, then you won't have the API calls to handle those dialogs.

Sorry for my weak English ....
In the original Buildozer Vm: (https://kivy.org/#download = buildozer -v 0.32 and python for android -v .04), the android api 26 and 27 are only accepted for release mode compilation, but for debugging will fail, the store accepts the apk, the bad thing is that I can not use sdl2, and it does not seem to download the api in fact, strange !! ..., thank you!.

Thank you, Zen-CODE, inclement, 40four, AndreMiras, SomberNight, for your time and effort.

I made my application with buildozer with the default configuration (api 19), I do not know how to change the targetSdk for my application to api 27?

SomberNight has already clarified that I can change the targetSdkVersion, but I do not know where or how to change that parameter. With Python for Android directly or with buildozer?

But I think it's better to wait for Zen-CODE to announce the release to a VM to build those APKs with instructions.

@inclement.
Frustrating. IRC seems blocked, so will post here.
Looking at the API 27 issue. When the app runs, we get an 'pythonutil: Library loading error: dlopen failed: cannot locate symbol "__aeabi_memclr8" referenced by "/data/app/org.test.myapp-1/lib/arm/libSDL2.so"' error.

Looking around, it seems these symbols were moved from LIBC to LIBC_N in the API 23 change.

https://android.googlesource.com/platform/bionic/+/6d142bcf34ffd49efaf4285bb2af63a1636706f9^!/

I find this change in 'android-nkd_r16b/platforms/android-23/arch-arm/usr/lib/lic.a' file in the NDK. But I'm not sure where we change this to make lbSDL2.so work?

About IRC, you may need to register your username to post at the moment due to an influx of spam. I thought we'd turned this off though, and have raised a query about it.

@Zen-CODE sorry about the IRC block. There was a ton of spam for a few of weeks so I had to block unregistered users from posting. Looks like it's finally over now, though, so I unblocked and anyone can post.

@Zen-CODE My Python 3 PR has some notes about this. In particular, introducing APP_PLATFORM set to an appropriate value is the fix for your __aeabi_memclr8__ issue, which I also saw along the way. Essentially, it means that SDL2 can be built against an older platform version even though the Java API target is much newer. We should have been setting this anyway, if it isn't set explicitly then as far as I can tell the NDK will pick a probably-wrong default value.

Anyone trying to target API 26 may like to try the set_app_platform_19 branch - I'm not certain if it will work, but it can't hurt.

Could APP_PLATFORM := android-19 be changed with APP_PLATFORM := $(APP_PLATFORM) and set it from the buid env?

Yep, I intend to make a proper PR for this if nobody else does first. I just made the branch to make it clear to people what the change is, so they can understand it and test easily if they want to do so immediately.

Edit: Specifically, I think the APP_PLATFORM should by default be the same as the minSdk: you wouldn't normally want it to be higher, and it's unlikely to need to be lower unless your minSdk is very new. However I would make it fully configurable.

@inclement. Progress. The app launches but on the device gives an "SDL Error" popup.

Error: dlopen failed: cannot locate symbol "ftello64" referenced by "/data/app/org.test.myapp-2/lib/arm/libpython2.7.so"...

Looking through the logcat output, this happens right after an error trying to find "libpython3.5m.so", but I doubt that's important now. This missing symbol seems to cause the crash...

What targetSDK, compileSDK, NDK_PLATFORM and minSDK are you using?

The spec file only contains "android.api = 27, android.sdk=23" and the ndk path is to the the extracted "android-ndk-r16b"

And you're using my set_app_platform_19 branch, or otherwise setting the APP_PLATFORM some other way?

Yeah, using that branch. And starting without any previous .buildozer folder in the app directory. And device is android 6 (API level 23 I believe)

Update. The "set_app_platform_19" branch still works with android.api = 19. The log also shows the python3.5m error but then carries on loading the other libs as normal. ...

hi, i have working on android package with api 27 ,i add APP_PLATFORM := android-12 to pythonforandroid/bootstraps/sdl2/build/jni/Application.mk then package, got the same error as @Zen-CODE report
Error: dlopen failed: cannot locate symbol "ftello64" referenced by "/data/app/org.test.myapp-2/lib/arm/libpython2.7.so"...

vm setup:
ubuntu 16.04 python2.7 kivy 1.10.1 cython0.25.2
p4a==master sdk api level=27 ndk r16b build tool 27.0.3

any suggestion? i have deal with it almost one week and feel so despair

I think that the SDK API 26 version can not be packaged,that's horrible. Hope that it will be fixed sooner,I love KIVY project.

I was able to build my app with gradle (from buildozer) using the following:

android.api = 27
android.minapi = 19

Importantly, when uploaded to Google Play there is no message saying I am targeting old API.
I have build tools version 28.0.2, but I was also successfully building and uploading to Google Play using 26.0.1
Admob ads seems to be working fine too using default bootstrap (I am using monkeypatched Kivmob version).

Using p4a cloned about a week ago and kivy=master. Latest version of buildozer.

There are a couple of issues I did not manage to resolve yet:
1) At the end of the process I get the following output:
To run dex in process, the Gradle daemon needs a larger heap.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.

Unfortunately, even adding this line to all gradle.properties files in .buildozer folder and my p4a directory does not result in any change to this message. This is basically means there are very few SDK I can add to my App (at least this is how I read it - I might be wrong)

2) Due to my app targetting API=27, all permissions required have to be requested dynamically when user runs the app for the first time. User should have a dialog to either allow or deny each permission like "write external storage". Unfortunately, there is no handle for this in kivy yet, so it is a major problem. The only work around I see is to write a message to the user and explain how to grant permissions manually. Terrible user experience.

@clevermindgames. Using the same setting, I get the "ftello64" error. But I have build tools 23, 25 + 28 installed. How do you specify which one to use? Also, which SDK version are you using?

re: point 2. Is there a way to do that even in Java? I would have thought on a per-request basis is how later versions of android handle the issue by default....

Just fyi I'm currently successfully publishing https://github.com/HelloZeroNet/ZeroNet-kivy for SDK 26 with the following config: https://github.com/HelloZeroNet/ZeroNet-kivy/blob/master/buildozer.spec#L81-L91
Note that I'm using a custom tool https://github.com/HelloZeroNet/ZeroNet-kivy/tree/master/buildozer-android-downloader to download the newer SDKs / NDKs and my own fork of p4a with some PRs merged in https://github.com/mkg20001/python-for-android/

@mkg20001 zeronet alpha#10 crash on andriod 6.0 (samsung) , work well on Android8.0/8.1. it seems package with api 26 can't compatible with Android 6.0 and below.

Didn't notice this myself because I use android 8.1.
Is there any fix available?

海森堡测不准面包 notifications@github.com schrieb am Do., 20. Sep. 2018, 07:57:

@mkg20001 https://github.com/mkg20001 zeronet alpha#10 crash on andriod
6.0 (samsung) , work well on Android8.0/8.1. it seems package with api 26
can't compatible with Android 6.0 and below.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-423049396,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHYHaUi6ZePshs17_fUnYiRpBX6LKzOFks5ucy5GgaJpZM4RZ5U5
.

@clevermindgames. Using the same setting, I get the "ftello64" error. But I have build tools 23, 25 + 28 installed. How do you specify which one to use? Also, which SDK version are you using?

From Android SDK manager:
Android SDK Tools: 25.2.5
Android SDK Platform Tools: 28.0.1
Android SDK Build-tools: 28.0.2, 26.0.1, 23.0.1, 19.1
SDK Platform: 28, 27, 26, 19 (targeting 27 in buildozer, 28 and 26 did not work)
Extras -> Android Support Repository: 47
Have serious doubts I really need them all, just did not bother to remove those which did not work out
It always uses the highest version available, so if I need to use build-tools 26.x over 28.x I just open SDK manager and uninstall 28.x

I also did not work with android.minapi lower than 19. Might be due to some poor back compatability

re: point 2. Is there a way to do that even in Java? I would have thought on a per-request basis is how later versions of android handle the issue by default....

There was no solution 4 months ago, but it looks to be feasible:
https://www.reddit.com/r/kivy/comments/8kl10p/is_there_a_way_to_implement_runtime_permissions/

@mkg20001. Thanks a lot for the info. Will look into that. What versions of Android have you tested on?

@clevermindgames. Okay, I'm also experimenting with using Android studio to manage the SDK's and API's. I've now built using API 27 + SDK 28 + Platform tools 28 but still hitting the 'ftello64' error when running the app....Also using 19 as minapi.

@Zen-CODE Currently only 8.1. From user feedback it seems like the app crashes on any device below API 26 but I have no idea what could be causing this.
Example: https://github.com/HelloZeroNet/ZeroNet/issues/1624 but there are many more of these (this is the most common crash)

With the same settings as @Zen-CODE , the same error when I launch my APK on android 6
Error: dlopen failed: cannot locate symbol "ftello64" referenced by "/data/app/org.test.myapp-2/lib/arm/libpython2.7.so"

When I launch the same APK on android 7 the device gives this error
System.err: dlopen failed: cannot locate symbol "ctermid" referenced by "/data/app/com.cassetete-1/lib/arm/libpython2.7.so"

OK my app build with NDK r16b and API 27. No more errors related to ftello64.

In first build with API 19, when it's good remove your dist from .buildozer/android/platforms/build/dists and re-build with API 27.

I have upload my APK to Play Store without errors related to API used.

So now when I launch my APK I have an error
09-24 00:29:00.352 26402 26448 I python : File "/home/malak/Documents/casse_tete/.buildozer/android/platform/build/dists/labyrinthecassetete/private/lib/python2.7/site-packages/kivy/app.py", line 780, in user_data_dir 09-24 00:29:00.353 26402 26448 I python : OSError: [Errno 13] Permission denied: '/sdcard/cassetete'
This error is related to WRITE permission, I work around this now.

If I remove the lines who used user_data_dir, it works!!

Tested on Android 6.

Well done, I had no idea API 19 was required, never seen dlopen failed error myself. Looks like I got it (API 19 -> API 27 ) by accident since my previous builds were targetting API 19 anyway.

Spent quite a lot of time trying to find a way to store data in internal (private) storage for the app so it is not getting deleted every time user exits the app. Here is the solution:

from kivy.utils import platform
if platform.lower() == "android":
        from jnius import autoclass, cast
        PythonActivity = autoclass('org.kivy.android.PythonActivity')
        Environment = autoclass('android.os.Environment')
        context = cast('android.content.Context', PythonActivity.mActivity)
        private_storage = context.getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath();

For some perspective on why the API 19 build works: I think you are effectively achieving the same thing as setting APP_PLATFORM, such that the NDK libraries are built for api 19 even though the APK target API is higher. This is actually a kind of bug in p4a, it should not use the same build in this case.

@StacyMAI. Thanks a lot for sharing that, but I am confused. I've used the same NDK and API, and the same "build for 19 then 27" approach but got reports that the APK was still refused by google. The only difference is that you clear the "dists" folder before rebuilding. I can confirm it solves the ftello error and runs on my phone, but I will reserve my explosions of gratitude and wonder when the store accepts the APK.

Unfortunately, it will take me a little while to test that. Our current app only builds with the old toolchain, so I need to solve those issues before I can build a new APK and upload. I will post back when I can confirm that it is accepted. Until then, I would encourage others to post their findings when using this process and uploading.

Hi all,

I currently try to update my app as well. Following is defined in my buildozer.spec:

android.api = 27
android.minapi = 19
android.sdk = 23
android.ndk = 16b

I deleted all buildozer stuff and started completly from scratch. First I had to download NDK r16b manually, because the automatic download failed and define the NDK location in the spec file like so:

android.ndk_path = ~/.buildozer/android/android-ndk-r16b

Next i applied the changes from https://github.com/kivy/python-for-android/compare/set_app_platform_19 on my p4a fork (after merging changes from master).

Then I needed to modify ~/.buildozer/android/platform/android-sdk-23/tools/ant/build.xml and set java.source and java.target to 1.7.

I ran into System.err: dlopen failed: cannot locate symbol "..." referenced by ... errors with ctermid and setpwent for which i added patches disabling the code using them here https://github.com/rnixx/python-for-android/compare/master...rnixx:ctermid_getpwall_patches

Looking into the related code from python 2.7.2, these patches might be obsolete if I find a way for setting values at cmmi configure time, when pyconfig.h gets generated from pyconfig.h.in. It looks like default values are taken from how system or hostpython was compiled. Unsetting HAVE_CTERMID and HAVE_GETPWENT will probably do the trick, however, i have no idea how to achieve this.

Finally the apk builds, but now i get random ImportError: dlopen failed: file offset for the library "/data/user/0/.../files/app/lib/python2.7/site-packages/kivy/_...so" >= file size: 0 >= 0 for several modules. _properties.so, _event.so and android.runnable are such candidates. For each build it's always the same missing module, but when deleting the build and rebuilding the apk, some other stuff is missing. I have no idea what's going on here and would be really glad if someone point me in the right direction.

Thanks, Robert

@Zen-CODE Another aspect of p4a's buggy target api handling is that dists are fixed to a specific target api once created. It's written to one of their config files. I only realised this recently, I realise it must have caused quite some confusion.

@rnixx The problem here is probably not that they have file size 0 (which is true and actually okay), but that libpymodules.so has not been included or loaded as it should be. That file should provide the symbols you need. When it hasn't been loaded the error message is misleading because it doesn't know about the slightly weird symbol redistribution p4a does.

@inclement for some reason the libs are now included properly, maybe because i changed the requirements recipe order. don't know.
further android recipe was missing. now - hopefully the final issue - i get a permission denied error to the SD card, even if READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions are granted. do you have an idea what's missing?

@StacyMAI. Thanks a lot for sharing that, but I am confused. I've used the same NDK and API, and the same "build for 19 then 27" approach but got reports that the APK was still refused by google. The only difference is that you clear the "dists" folder before rebuilding. I can confirm it solves the ftello error and runs on my phone, but I will reserve my explosions of gratitude and wonder when the store accepts the APK.

Unfortunately, it will take me a little while to test that. Our current app only builds with the old toolchain, so I need to solve those issues before I can build a new APK and upload. I will post back when I can confirm that it is accepted. Until then, I would encourage others to post their findings when using this process and uploading.

I tested building with 19 and then removing the dists folder as suggested by @StacyMAI but upon opening my app I get:
IOError: [Errno 13] Permission denied: '/storage/emulated/0/OptiLEAVE/saved_data/currentuser.xml'

This is just reading an xml which is previously saved data.

The app has read and write permissions in the spec file.

I can also confirm that in using this method, play console does see the API as 27.

Are these various read and write issues just caused by the fact that permissions changed in Android 26 or so: now you have to ask for them with the java api, I haven't tried this.

I would have thought that would be something that android handled itself.

@inclement you're right. if i go to settings -> apps and choose my app, storage permission is denied by default. when i grant permission manually, it works. will try to find a way to ask user for permission via jnius

you were faster ;) just found it. this code might go to PythonActivity, and then be invoked from jnius or android, what do you think?

Regarding the permission denied on /storage for me it was due to user_data_dir from kivy.app.

I have just tested the solution of @clevermindgames

from jnius import autoclass, cast
PythonActivity = autoclass('org.kivy.android.PythonActivity')
Environment = autoclass('android.os.Environment')
context = cast('android.content.Context', PythonActivity.mActivity)
private_storage = context.getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath()

And it work fine, thanks @clevermindgames! private_storage return path /storage/emulated/0/Android/data/com.myapp/files/data

I can write to a file in this path without problem.

Regarding the tools version I used for my build
buildozer latest version installed from pip
p4a latest version downloaded from github (zip file)
android-ndk r16b downloaded manually
android-sdk, I used my old version android-sdk-20 full updated with android tool (sdk tools,build-tools, platform-tools)
openjdk-8

I have modified android-sdk-linux/tools/ant/build.xml

<property name="java.target" value="7" />
<property name="java.source" value="1.7" />

buildozer.spec

android.api = 19
android.minapi = 19
android.sdk = 23
android.ndk = 16b

I also modified some p4a files related to sdl2; check to this commit https://github.com/kivy/python-for-android/commit/f017eb9254c4dc179524e8d6e26f58600a39695a. Thanks @inclement for that.

But I had modified these files due to "__aeabi_memclr8" error. But this error appear when you build your app directly with API27. So I think this modification is not necessary because building in first with API19.

I hav build with API19, removed my dist directory and re-build with API27.

Many thanks to all. KIVY DEV team and community are great!!

Sorry for my english, I hope you understand me.

@Zen-CODE. You must remove your dist after build with api19 because some
files are «tagged» api19. This first build is just for compile libraries
because it work with this api version.
I hope it will work for you.

Le 24 sept. 2018 8:25 PM, "Richard Larkin" notifications@github.com a
écrit :

@StacyMAI https://github.com/StacyMAI. Thanks a lot for the sharing that,
but I am confused. I've used the same NDK and API, and the same "build for
19 then 27" approach but got reports that the APK was still refused by
google. The only difference is that you clear the "dists" folder before
rebuilding. I can confirm it solves the ftello error and runs on my phone,
but I will reserve my explosions of gratitude and wonder when the store
accepts the APK.

Unfortunately, it will take me a little while to test that. Our current app
only builds with the old toolchain, so I need to solve those issues before
I can build a new APK and upload. I will post back when I can confirm that
it is accepted. Until then, I would encourage others to post their findings
when using this process and uploading.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/kivy/python-for-android/issues/1219#issuecomment-424076003,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AfrTeHbZPP-zja_GOJxtfnaKi1csoXFQks5ueSOjgaJpZM4RZ5U5
.

So I've had success in building (with buildozer) and uploading my app to the play store using @StacyMAI 's method, however I'm having trouble getting the app to work with AdMob/KivMob. Currently when I attempt to run the app and it tries to use kivmob I get this error:

jnius.jnius.JavaException: Class not found 'org/kivy/android/PythonActivity$AdCmd'

The app works as expected when I comment out all the kivmob code.

Previously I built the app with python3crystax, python-for-android-admob/sdl2-admob and the ads worked as expected then, but then the API requirement went into effect and I haven't been successful building an apk with the crystax ndk so I've reverted to python2.7 and used @StacyMAI 's method which solved the API requirement problem but brought upon the issue with Admob.

I'm guessing it has something to do with not initially setting in my buildozer.spec the p4a source_dir to python-for-android-admob and p4a bootstrap to sdl2-admob, but I'm really not sure and am at a loss for where to go from here. I've tried setting the p4a source/bootstrap to the admob ones after an initial successful build, but the error still persists when I run the app, and when I set p4a source/bootstrap to the admob initially (before a successful build) I get a different error and the build is unsuccessful:

Include/Python.h:33:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>

Any thoughts on what I could try from here to get Admob working?

Any thoughts on what I could try from here to get Admob working?

I have got Admob to work on API 27, here is the link: https://play.google.com/store/apps/details?id=au.com.quadropoly.quadropoly

I am not using custom bootstrap, instead I forked p4a and modified pythonforandroidbootstrapssdl2buildsrcmainjavaorgkivyandroidPythonActivity.java inserting all the bits from sdl2-admob's PythonActivity.java file (the bits to insert are very well marked by /* KivMob backend starts here. / and / End of KivMob code. */, great work MichaelStott! )
There is no need to insert google-play-services.jar as libs required could be added via buildozer:
android.gradle_dependencies = 'com.google.android.gms:play-services-ads:15.0.0','com.android.support:appcompat-v7:26.1.0'

Hope it helps. At this point only banners and interstitial are working, but I am trying to add support for Rewarded Videos too.

@clevermindgames I've added the sdl2-admob's PythonActivity.java KivMob code to the regular p4a's PythonActivity.java and when trying to build it looks like it's nearly successfully completing but I get an error:

> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find com.google.android.gms:play-services-ads:15.0.0.

and the same for com.android.support:appcompat-v7:26.1.0. I put those into my buildozer.spec for the gradle_dependecies but it doesn't seem to loading them properly. I'm pretty new to all of this so I could be missing something simple. Could I add the google-play-service.jar manually and if so where should it go? I'll keep poking around and hopefully I'm stumble on a solution, but thanks for the help and getting me started in the right direction!

Regarding the permission denied on /storage for me it was due to user_data_dir from kivy.app.

I have just tested the solution of @clevermindgames

from jnius import autoclass, cast
PythonActivity = autoclass('org.kivy.android.PythonActivity')
Environment = autoclass('android.os.Environment')
context = cast('android.content.Context', PythonActivity.mActivity)
private_storage = context.getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath()

And it work fine, thanks @clevermindgames! private_storage return path /storage/emulated/0/Android/data/com.myapp/files/data

I can write to a file in this path without problem.

This does work so thanks for that, however it is extremely slow at reading and writing data compared to writing to sdcard, assuming due to the jnius.

Getting permissions is still key here I think.

As far as admob goes, maybe having a discussion on the kivy users group would be extremely beneficial to a lot of people?

@tkuam No, don't add .jar manually: you can only get very old version of this library as a .jar and I doubt it will work properly with API 27.
Try modifying this file, so the top 22 rows look like this
pythonforandroidbootstrapssdl2buildtemplatesbuild.tmpl.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
       jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
    }
}

allprojects {
    repositories {
        jcenter()
    mavenCentral()
    maven {
            url "https://maven.google.com"
        }
        flatDir {
            dirs 'libs'
        }
    }
}

Don't forget to buildozer android clean before rebuilding when modifying anything in p4a: it copies files from there only when it is clean.

@OptimusGREEN getting this folder through jnius is slow, but you only need to do it once. Just store the results in some StringProperty and use it everywhere.
Google labeled those permissions dangerous for a reason, and unless it is really required for the app it should be avoided. I used it to be able to share saved data between paid and free version of my App, now learning to live without it.
There is also a benefit in using private storage for the app: when user backs up his phone's data, his SDcard content is not saved in a backup.

Okay, I can confirm the build APK per StaceyMAI's procedure runs without the ftello error AND is accepted by google. Yay. Thanks all.

@inclement. You mentioned a config file that incorrectly stores the previous config. Which one? If you give me some pointers, I can try to prepare a PR to fix that?

project.properties is the file.

@clevermindgames I modified build.tmpl.gradle as you suggested and that seems to solve the need to find play-services-ads as my log shows it's been downloaded during the build, but now I've got a bunch of these errors for what seems like all of the various android widgets:

/home/tkuam/Desktop/wcpy2/.buildozer/android/platform/build/dists/workoutapp/build/intermediates/res/merged/debug/values-v26/values-v26.xml:14: error: Error: No resource found that matches the given name: attr 'android:touchscreenBlocksFocus'.

Not sure if it's related to the kivmob/admob changes or not, but I don't get these errors and successfully build when I don't make those changes.

Edit: Been poking around a bit, when I go to the directory and open up the .xml file(s) indicated in the error messages I'm getting, I'm finding the line that the error is referring to: <item name="android:touchscreenBlocksFocus">true</item> and I see that everything has to do with AppCompat (as in gradle_dependencies = 'com.android.support:appcompat-v7:26.1.0' from the buildozer.spec file perhaps?). Not sure entirely what I'm looking at in these files in my limited programming experience but maybe that gradle dependency is not working as it should?

@tkuam this error basically means your build tools are incompatible with com.android.support:appcompat version. I will write up a more detailed guide how to get it to work with all the moving pieces put together in the next couple of days

@clevermindgames okay yeah that's the conclusion I came upon after doing some googling. Thanks for working on a detailed guide. In the meantime I'll see if I can't mess around with the build tools version and get it working.

@tkuam Here is the guide: http://quadropoly.com.au/kivy-and-admob-for-android-api-27/
Please let me know if it works for you. Let's discuss it there in the comments to stop hijacking this conversation :)
Update: I have simplified the integration and added support for Admob Rewarded Videos if anyone is interested: https://quadropoly.com.au/kivy-and-admob-for-android-guide-part2/

Hello, @StacyMAI! I was reading through these comments and I noticed you mention "aeabi_memclr8"

When I try to build my app, it compiles the debug APK but crashes at start. I read the logcat file and it came back with: cannot locate symbol "__aeabi_memclr8"

Would you, or anyone else, know how to fix this issue? Thank you!

@Petar-Luketina I think this issue is likely to be caused by compiling against an api level higher than your device supports. There isn't currently a good way around this, it's a bug in p4a, although there are workarounds (I think discussed earlier in this thread).

That's better news! Thanks @inclement . Would the app work if I uploaded it on to the app store, then downloaded it on the same phone from there?

UPDATE:
@inclement Hey, so I tried to upload it on the app store and there are many errors that came back from the testers. I also tried to upload it on a newer phone, and the app still crashes.

Here is the error logs from Google:

Issue: java.lang.UnsatisfiedLinkError: No implementation found for void org.libsdl.app.SDLActivity.nativeSetEnv(java.lang.String, java.lang.String) (tried Java_org_libsdl_app_SDLActivity_nativeSetEnv and Java_org_libsdl_app_SDLActivity_nativeSetEnv__Ljava_lang_String_2Ljava_lang_String_2)

Any insight?

@Petar-Luketina have you tried this ?
In first build with API 19, when it's good remove your dist from .buildozer/android/platforms/build/dists and re-build with API 27.

Ah, I skimmed over the part that said to make the 19 API then delete the dists and re-build to API 27, my mistake.

It works fine on debug mode, but it's crashing when I download it from the app store. I'm going to keep working at the problem. Maybe I'm missing something else.

@StacyMAI , if I may suggest an edit though. Your above post says to change 1.5 to 1.7:

<property name="java.target" value="7" />
<property name="java.source" value="1.7" />

But I had to change both to 1.8 because that's my version of Java (that's what that number is, correct?). Perhaps suggesting either one of those two may lead the next person to less confusion.

@Zen-CODE Any news from that VM plan of yours? :o)
I'm in widows and I rely on the Kivy's android VM (v2.0) to build apks for my apps.
Is the building process still more complicated that the old one, so it's not possible with a VM?

@noembryon. There is not much to more to add to it at this point. It builds for API 27 with the "API 19, clear dists, build for 27" process. I'm working on fixing that but blocked by my python-for-android service dying on imports. That's also really import to get working for us, so I'm trying to sort that out before releasing a new VM...

@Zen-CODE Yes, I understand.
Thank you for your (and the other guys) work on this.
It is greatly appreciated..

I created a solution that at the moment makes inclusion possible, it is extremely beta, but it already works for me.

https://github.com/atnccetti/launcherKivyAndroid

@atnccetti. Thanks. There are a few issues around python services and pyjnius that I want to resolve before redoing the VM. When I get there, I'll definitely look at this. Thanks :-)

Should we close that one since https://github.com/kivy/python-for-android/pull/1412 was merged?

Does that mean that there will be a new Virtual Image for us poor windows users? ;o)

For my 2c, there are more issue around this than the python3 recipe. Python2? And until there is a buildozer.spec file that can build a python2/python3 APK from scratch, I think it best to keep it open....

Hi guys :)
in the last month i built up from scratch an Ubuntu 18.10 x64 VM image with VirtualBox 5.2.22 especially for Python-for-Android builds ;)
@inclement i want this project to succeed and i will try my best to play as a Beta-Tester (I'm not a pro developer, I'm just a 1st-2nd level Desktop Support & Service Desk IT technician guy...)

So here below the VM specs (full details in attachments):

  • Ubuntu 18.10 x64 on VirtualBox 5.2.22 with GuestAddons 5.2.22 ready (FULLY updated as of 7 Dec)
  • GCC 8.2 & Clang 7
  • Python-for-Android Master Branch (updated as of 7 Dec)
  • Android SDK CLT 26.1.1 & Android NDK r16b + r18b
  • OpenJDK 8

As you can see from the r16b build log, i was able to make the APK (API 26, ARM64, Python3) but unfortunately my Oreo phone doesn't even let install the package (error during package analysis).
I have to check more deeply the build logs...but for now i think that it's a step in the right direction :)
BuildLog_NDKr16b_API26_ARM64.log
BuildLog_NDKr18b_API26_ARM64.log
SdkManager_list.txt
PIP&PIP3_List.txt
Ubuntu_APT_List.txt

@RezVIKONG. The build succeeds it seems, so the logs you've posted I don't really help us (as far as I can tell anyway). If deployment to the phone fails, we need to see why. That can (hopefully) be done by examining the output of

buildozer android debug deploy run logcat

whilst your device is connected. The output of the logcat command should indicate why the deployment fails.

Also, I would suggest continuing this discussion by posting on the kivy user group. This ticket is long and ready for closing, as support for API 26+ has been achieved.

Any references to "support for API 26+ has been achieved", please?

I am currently unable to build a webview bootstrap with python3 and flask, using target api 27.
Also the suggestion to "build for 19" does not work since python3 recipe requires api 21+.

Thanks for all the work so far.

@MisterY p4a now properly supports different build versions in a way it didn't before, but only with the sdl2 bootstrap. The work @JonasT has been doing to unify the bootstraps has moved towards fixing this in the other ones as well (especially webview), but I don't think this particular issue is covered yet. There are a few other outstanding build target problems that I hope to look at together over Christmas.

Also the suggestion to "build for 19" does not work since python3 recipe requires api 21+.

You can just substitute 21 for 19 and it should work the same way. However, the webview bootstrap might have issues right now with the master branch so you may need to make sure your p4a is not quite up to date.

@inclement, thanks a lot for the tips. I'm creating a Discord account for further discussion. I'm really hoping to get at least something going and would be looking to help as much as I can.

@MisterY For what it's worth, it shouldn't be very hard to make it work.

Was this page helpful?
0 / 5 - 0 ratings