diff --git a/java/build-android.gradle b/java/build-android.gradle index d2ab321749efa..de850aafe4643 100644 --- a/java/build-android.gradle +++ b/java/build-android.gradle @@ -171,7 +171,7 @@ publishing { if (addQnnDependency) { println "Modifying the POM XML to include QNN dependency" - def qnnVersion = project.hasProperty('qnnVersion') + def qnnVersion = System.properties['qnnVersion'] qnnVersion = "$qnnVersion.+" withXml { diff --git a/tools/ci_build/github/android/build_aar_package.py b/tools/ci_build/github/android/build_aar_package.py index fef636125b2bc..7cc36cc5d350f 100644 --- a/tools/ci_build/github/android/build_aar_package.py +++ b/tools/ci_build/github/android/build_aar_package.py @@ -102,6 +102,9 @@ def _build_aar(args): if qnn_android_build: qnn_home = os.getenv("QNN_HOME") + qnn_sdk_version = os.getenv("QNN_SDK_VERSION") + if not qnn_sdk_version: + raise EnvironmentError("QNN_SDK_VERSION environment variable is not set.") abi_build_command += ["--qnn_home=" + qnn_home] if ops_config_path is not None: abi_build_command += ["--include_ops_by_config=" + ops_config_path] @@ -163,6 +166,10 @@ def _build_aar(args): ("-DaddQnnDependency=1" if qnn_android_build else "-DaddQnnDependency=0"), ] + # Add qnn specific parameters + if qnn_android_build: + gradle_command.append(f"-DqnnVersion={qnn_sdk_version}") + # clean, build, and publish to a local directory subprocess.run([*gradle_command, "clean"], env=temp_env, shell=False, check=True, cwd=JAVA_ROOT) subprocess.run([*gradle_command, "build"], env=temp_env, shell=False, check=True, cwd=JAVA_ROOT)