aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-09-21 11:16:06 +0200
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-09-21 13:09:23 +0200
commit833f1143bc283b85454f9023e53cf89c81bc36cc (patch)
tree2b8e22af0a1bf140c4083f49799f6bf6e479da14 /sources/pyside-tools
parenta0d131603dc9133ce7c22ff9dd2e3f21db397a44 (diff)
Android Deployment: Add static_init_classes
- The `jar` xml element in the dependency files shipped with Qt for Android sometimes has a 'initClass' field which depicts the full qualified name of the class in the jar file. When available, this is to be added to libs.xml (used by Qt for Android to list the dependencies of the app) to identify the specific class being referenced. The element name for this in `libs.xml` is called `static_init_classes`. Task-number: PYSIDE-1612 Pick-to: 6.6 Change-Id: I184ea06e36054ebe70da5a81da48a732287016dc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools')
-rw-r--r--sources/pyside-tools/deploy_lib/android/buildozer.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/sources/pyside-tools/deploy_lib/android/buildozer.py b/sources/pyside-tools/deploy_lib/android/buildozer.py
index 1465ea3f1..e6a954c62 100644
--- a/sources/pyside-tools/deploy_lib/android/buildozer.py
+++ b/sources/pyside-tools/deploy_lib/android/buildozer.py
@@ -76,17 +76,20 @@ class BuildozerConfig(BaseConfig):
local_libs = ",".join(pysidedeploy_config.local_libs)
- extra_args = (f"--qt-libs={modules} --load-local-libs={local_libs}")
- self.set_value("app", "p4a.extra_args", extra_args)
-
# add permissions
permissions = self.__find_permissions(dependency_files)
permissions = ", ".join(permissions)
self.set_value("app", "android.permissions", permissions)
- # add jars
- jars = self.__find_jars(dependency_files, pysidedeploy_config.jars_dir)
+ # add jars and initClasses for the jars
+ jars, init_classes = self.__find_jars(dependency_files, pysidedeploy_config.jars_dir)
self.set_value("app", "android.add_jars", ",".join(jars))
+ init_classes = ",".join(init_classes)
+
+ #extra arguments specific to Qt
+ extra_args = (f"--qt-libs={modules} --load-local-libs={local_libs}"
+ f" --init-classes={init_classes}")
+ self.set_value("app", "p4a.extra_args", extra_args)
# TODO: does not work atm. Seems like a bug with buildozer
# change buildozer build_dir
@@ -126,7 +129,7 @@ class BuildozerConfig(BaseConfig):
return permissions
def __find_jars(self, dependency_files: List[zipfile.Path], jars_dir: Path):
- jars = set()
+ jars, init_classes = set(), set()
for dependency_file in dependency_files:
xml_content = dependency_file.read_text()
root = ET.fromstring(xml_content)
@@ -139,19 +142,26 @@ class BuildozerConfig(BaseConfig):
else:
logging.warning(f"[DEPLOY] Unable to include {jar_file}. "
f"{jar_file} does not exist in {jars_dir}")
+ continue
else:
logging.warning(f"[DEPLOY] Unable to include {jar_file}. "
"All jar file paths should begin with 'jar/'")
+ continue
+
+ jar_init_class = jar.attrib.get('initClass')
+ if jar_init_class:
+ init_classes.add(jar_init_class)
# add the jar with all the activity and service java files
# this is created from Qt for Python instead of Qt
+ # The initClasses for this are already taken care of by python-for-android
android_bindings_jar = jars_dir / "Qt6AndroidBindings.jar"
if android_bindings_jar.exists():
jars.add(str(android_bindings_jar))
else:
raise FileNotFoundError(f"{android_bindings_jar} not found in wheel")
- return jars
+ return jars, init_classes
def __find_local_libs(self, dependency_files: List[zipfile.Path]):
local_libs = set()