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

Enhancement Request - Custom Java #1563

Open
RobertFlatt opened this issue Jan 1, 2019 · 4 comments
Open

Enhancement Request - Custom Java #1563

RobertFlatt opened this issue Jan 1, 2019 · 4 comments

Comments

@RobertFlatt
Copy link
Contributor

Versions

  • Python:
  • OS:
  • Kivy:
  • Cython:

Description

Add a p4a command line option to specify a folder containing custom java classes.

During build the folder and contents would be copied to the javaclasses folder, for example:

cp -r <option argument> .local/share/python-for-android/build/javaclasses/<project>/
Example usage:
--fantastic_new_custom_java_option=~/greatproject/com

Where custom java located here:
~/greatproject/com/company/project/custom.java

Something similar is supposed to exist in buildozer, implementation issues suggest a need for redundancy.

buildozer.spec

Command:

Spec file:

Logs

// REPLACE ME: Paste the build ouput containing the error
@ghost
Copy link

ghost commented Jan 2, 2019

There is an --add-jar option internally in the build.py bootstrap script. I think you might be able to just specify it for p4a (which if I recall correctly passes unknown options through to the bootstrap build script) and that would copy your specified .jar files into the libs folder. That may already be enough to get that to work, but you'll have to give it a try and see if that actually does the job especially regarding them actually being loaded at runtime when added like that, I'm just guessing from vague source code memories here

@RobertFlatt
Copy link
Contributor Author

The option is there in toolchain.py , but gradle fails

[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]:
[DEBUG]:        > Configure project :
[DEBUG]:        WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
[DEBUG]:        It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
[DEBUG]:
[DEBUG]:
[DEBUG]:        FAILURE: Build failed with an exception.
[DEBUG]:
[DEBUG]:        * What went wrong:
[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.
[DEBUG]:
[DEBUG]:        * Try:
[DEBUG]:        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[DEBUG]:
[DEBUG]:        * Get more help at https://help.gradle.org
[DEBUG]:
[DEBUG]:        BUILD FAILED in 6s
[DEBUG]:        14 actionable tasks: 3 executed, 11 up-to-date
[DEBUG]:
[DEBUG]:

Jar file build, using the jnius example file, and changing the first line to "package com.fishes;"

jar cvf jartest.jar com
added manifest
adding: com/(in = 0) (out= 0)(stored 0%)
adding: com/fishes/(in = 0) (out= 0)(stored 0%)
adding: com/fishes/Hardware.java(in = 1370) (out= 509)(deflated 62%)

@inclement
Copy link
Member

Noted by @OptimusGREEN that /.buildozer/android/platform/build/dists//src/main/libs/ was the correct location for libs to be copied.

@AndreMiras
Copy link
Member

AndreMiras commented Feb 9, 2019

Can you tell if this is fixed via #1693 ?
Edit: Yes I could reproduce the gradle Failed to transform file issue

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

No branches or pull requests

3 participants