python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

Bootstrap backend for Android Library project

Open xuhcc opened this issue 6 years ago • 4 comments

Added new bootstrap backend for packaging python service as Android library.

Resolves #1957

I'm not familiar with python-for-android codebase, so I tried to keep changes to existing modules to a minimum. Some files (e.g. jtar classes) are simply copied from the service_only bootstrap. I'm not sure what's the best approach here. Maybe we can move them to bootstraps/common?

xuhcc avatar Aug 22 '19 21:08 xuhcc

Looking good overall. I'd still like to dig more before we can merge. I'm just pretty sad to see we still need quite a lot of copy pasta for adding new bootstrap. We were supposed to mitigate it via https://github.com/kivy/python-for-android/pull/1496 and https://github.com/kivy/python-for-android/pull/991 but we still have a lot to do it seems.

AndreMiras avatar Aug 23 '19 23:08 AndreMiras

I'm not clear from the code alone, what exactly is new/different in this bootstrap compared to (say) the service_only one? Would it be possible to make the aar thing a build option instead of a bootstrap?

inclement avatar Aug 24 '19 12:08 inclement

@inclement

The main difference is that in service_only bootstrap services depend on PythonActivity class. You need to start activity to extract python bundle and only after that you can start services.

For library bootstrap I moved the unpackData method to service class itself and added custom AssetExtract class which depend on Context instead of Activity.

I think it is possible to make it a build option for service_only bootstrap, but I'm not sure how to do it correctly.

xuhcc avatar Aug 24 '19 13:08 xuhcc

Thanks for the clarifications @xuhcc. My current thinking is that this would be preferable to add as functionality to one or more existing bootstraps, and to call it using a new p4a aar command instead of overloading apk (this would be much nicer in general than starting to add if statements based on the bootstrap type). However, I'm saying this from a position of not having really checked the details of how it needs to work.

inclement avatar Aug 31 '19 20:08 inclement