Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: copy additional jar files into the correct libs directory #1693

Merged
merged 1 commit into from
Feb 9, 2019
Merged

FIX: copy additional jar files into the correct libs directory #1693

merged 1 commit into from
Feb 9, 2019

Conversation

OptimusGREEN
Copy link
Contributor

This fixes the issue where additional jar files specified in the buildozer spec at android.add_jars aren't copied to the correct build directory resulting in a failed build attempt.

@AndreMiras
Copy link
Member

AndreMiras commented Feb 9, 2019

How did you get to test it to make sure it works? I'm getting an error during gradle build: Failed to transform file
Edit: Thanks for the PR by the way 😄

@OptimusGREEN
Copy link
Contributor Author

OptimusGREEN commented Feb 9, 2019

I forked master and edited the file. It ran straight through and copied over the jar files to the correct directory and completed successfully. Without this change I get an error saying my jar files can't be found at ...src/main/libs

So yeah works here.

Give me some time and I can share logs with and without if you like?

@AndreMiras
Copy link
Member

Oh thanks, well yes that's what I did, but I end up with the error described in #1563 (comment)
The error says:

[DEBUG]:        Could not resolve all files for configuration ':debugCompileClasspath'.
[DEBUG]:        > Failed to transform file 'jartest.jar' to match attributes {artifactType=android-classes} using transform JarTransform
[DEBUG]:           > Transform output file /home/bobf/.local/share/python-for-android/dists/ex/src/main/libs/jartest.jar does not exist.

@OptimusGREEN
Copy link
Contributor Author

Log with this pr (src/main/libs) - successful
https://paste.city/149

Log without this change (default libs) - error
https://paste.city/150

@AndreMiras
Copy link
Member

Thanks @OptimusGREEN very helpful debug session log.
I could eventually have it working in the Docker env after cleaning everything and building again from scratch.
The test command was:

python setup_testapp_python3.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --bootstrap sdl2 --requirements python3,kivy --add-jar ~/testapps/commons-compress-1.14.jar

With commons-compress-1.14.jar just being some random jar I first copied over to the ~/testapps/ dir for testing.
To start from clean build I ran the following command to delete everything related to previous builds:

rm -rf ~/.local/ ~/.gradle/ ~/.cache/ ~/.ccache/

Note that I may be deleting too much, but who cares in a Docker env 😄

@AndreMiras AndreMiras merged commit db53ef6 into kivy:master Feb 9, 2019
@RobertFlatt
Copy link
Contributor

Builds, but I get a runtime "Class not found".
I'm using the kivy:master with the commit, also tried OptimusGREEN:master this has the same behavior

the jar:

tst3>jar tf *.jar
META-INF/
META-INF/MANIFEST.MF
com/fishes/Hardware.java

Unzip the apk and I can see the jar contents at the root of the apk :

tst3/uz2>unzip *.apk
Archive:  ex-0.0.0-debug.apk
  inflating: AndroidManifest.xml
  inflating: META-INF/CERT.RSA
  inflating: META-INF/CERT.SF
  inflating: META-INF/MANIFEST.MF
 extracting: assets/private.mp3
  inflating: classes.dex
  inflating: com/fishes/Hardware.java
  ...and more lines...

Test python is:

    from jnius import autoclass
    def on_start(self):
        # This works:
        for m in dir(autoclass('org.jnius.NativeInvocationHandler')):
            print(m)
        # This crashes:
        for m in dir(autoclass('com.fishes.Hardware')):
            print(m)

And logcat says the jar contents is not found (the symbols before "Traceback" are from .NativeInvocationHandler) :

02-09 16:38:43.981 13493 13521 I python  : invoke
02-09 16:38:43.981 13493 13521 I python  : notify
02-09 16:38:43.981 13493 13521 I python  : notifyAll
02-09 16:38:43.981 13493 13521 I python  : pythonObjectPointer
02-09 16:38:43.981 13493 13521 I python  : toString
02-09 16:38:43.981 13493 13521 I python  : wait
02-09 16:38:43.981 13493 13521 I python  :  Traceback (most recent call last):
02-09 16:38:43.982 13493 13521 I python  :    File "/mnt/c/users/bobf/documents/pm/tst3/main.py", line 30, in <module>
02-09 16:38:43.982 13493 13521 I python  :    File "/home/bobf/.local/share/python-for-android/build/python-installs/ex/kivy/app.py", line 854, in run
02-09 16:38:43.982 13493 13521 I python  :    File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
02-09 16:38:43.982 13493 13521 I python  :    File "/mnt/c/users/bobf/documents/pm/tst3/main.py", line 19, in on_start
02-09 16:38:43.982 13493 13521 I python  :    File "/home/bobf/.local/share/python-for-android/build/python-installs/ex/jnius/reflect.py", line 159, in autoclass
02-09 16:38:43.983 13493 13521 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass
02-09 16:38:43.983 13493 13521 I python  :  jnius.jnius.JavaException: Class not found b'com/fishes/Hardware'

The jnius java file is (of course ) in the apk at :
assets/_python_bundle/site-packages/jnius/src/org/jnius/NativeInvocationHandler.java

Is this pilot error, or something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants