Question
Coforge
IN
Last activity: 6 Feb 2023 6:44 EST
Pega Mobile - Custom Module not able to resolve chaquopy python plugin
Hi, We are working on Pega mobile offline capabilities app and we have a requirement to execute a python program.
To execute Python Program we have created a custom module and defined the Python Plugin(com.chaquo.python) in the build.gradle.kts file of custom module. But when we are trying to build the code using devkit getting the below error.
Plugin [id: 'com.chaquo.python'] was not found in any of the following sources
Note: The same code and plugin when we put in the Non-Pega Android application, the plugin/dependencies complied and the build was successful.
DevKit Version using: 8.8.203
@Mateusz Pedzierski @matrm @RadoslawNowak @gabir @MarijeSchillern @VikasRaidhan @lukjj @augur @bondw Any inputs will be great helpful. Thanks
***Edited by Moderator Marije to add Support Case Details ***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 6 Feb 2023 6:44 EST
Pegasystems Inc.
PL
@SSrinivas I just noticed that the build.gradle.kts you posted above is the top level one. The repository has to be defined in the MODULE's build.gradle.kts similar to the below (full module gradle that I just checked)
@SSrinivas I just noticed that the build.gradle.kts you posted above is the top level one. The repository has to be defined in the MODULE's build.gradle.kts similar to the below (full module gradle that I just checked)
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.android.library")
kotlin("android")
id("gradle-pega-android-module")
}
group = "com.pega.testmodule"
version = "0.1-SNAPSHOT"
repositories {
maven {
url = uri("file://home/<USER>>/.m2/repository/")
}
}
android {
compileSdk = 33
defaultConfig {
minSdk = 23
targetSdk = 33
consumerProguardFiles("proguard-rules.pro")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.pega.mobile:vehicle-damage-reporting:0.3")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
testImplementation("junit:junit:4.12")
}
com.pega.mobile:vehicle-damage-reporting:0.3 is an AAR I deployed in my .m2 as maven artifact and this is (part of) the output of `packageModule`:
vehicle-damage-reporting is the AAR itself and vehicle-damage-modeling is a transitive dependency of the former.
Pegasystems Inc.
PL
@SSrinivas Custom modules support ordinary dependencies, not plugins which are part of the Gradle build process. Resolving plugins is made on project level, not particular module.
Depending on how such a plugin works, the binary (compiled) output of the module MIGHT work with PIMC, but not necessarily. It depends whether the plugin has to add something to the actual application or is it fully encapsulated in the output AAR package.
That library docs assume you're the owner of both the application source and the module, so it suggests adding the plugin in the top-level build file with a version (which you should not do since it WON'T be reflected in PIMC) and then adding the plugin to the module without versions. Since all your changes should be made within the module, you have to add the plugin with a version like this
id("com.chaquo.python") version "13.0.0"
to the module's build.gradle.kts file.
With this, you should be able to build and package the module, but PIMC might still either not build with it at all or encounter some runtime issues since plugins can, for example, add dependencies during the build phase without properly describing them as dependencies of the module.
Updated: 28 Dec 2022 11:17 EST
Coforge
IN
@gabir Thanks for your reply, we will modify the changes accordingly and give it a try.
Considering the scope of the Custom Module, we tried a different approach as well like maintaining Python Plugins/Dependencies in a separate AAR and this AAR will be defined as a dependency in the module's build.gradle.kts file.
With this approach when we tried to build from Devkit app, Custom Module and the AAR which we created both got bundled and the app was working fine.
But when we package the module and compile it from the mobile channel, it's failing with AAR not found error.
Logs are attached below.
@gabir Thanks for your reply, we will modify the changes accordingly and give it a try.
Considering the scope of the Custom Module, we tried a different approach as well like maintaining Python Plugins/Dependencies in a separate AAR and this AAR will be defined as a dependency in the module's build.gradle.kts file.
With this approach when we tried to build from Devkit app, Custom Module and the AAR which we created both got bundled and the app was working fine.
But when we package the module and compile it from the mobile channel, it's failing with AAR not found error.
Logs are attached below.
2022-12-26 14:58:44.037 INFO/MobileBuild: > Task :app:checkWebDebugAarMetadata
2022-12-26 14:58:44.038 INFO/MobileBuild: > Task :app:checkWebDebugAarMetadata FAILED
2022-12-26 14:58:44.039 INFO/MobileBuild: FAILURE: Build failed with an exception.
2022-12-26 14:58:44.040 INFO/MobileBuild: * What went wrong:
2022-12-26 14:58:44.041 INFO/MobileBuild: Execution failed for task ':app:checkWebDebugAarMetadata'.
2022-12-26 14:58:44.042 INFO/MobileBuild: > Could not resolve all files for configuration ':app:webDebugRuntimeClasspath'.
2022-12-26 14:58:44.043 INFO/MobileBuild: 11 actionable tasks: 11 executed
2022-12-26 14:58:44.044 INFO/MobileBuild: > Could not find com.example.servicelibrary:servicelibrary:1.0.
2022-12-26 14:58:44.045 INFO/MobileBuild: Searched in the following locations:
2022-12-26 14:58:44.046 INFO/MobileBuild: - file:/home/customizer/.m2/repository/com/example/servicelibrary/servicelibrary/1.0/servicelibrary-1.0.pom
2022-12-26 14:58:44.047 INFO/MobileBuild: - file:/opt/customizer/build/customize/repository/com/example/servicelibrary/servicelibrary/1.0/servicelibrary-1.0.pom
2022-12-26 14:58:44.048 INFO/MobileBuild: - file:/opt/customizer/build/customize/modules/com/example/servicelibrary/servicelibrary/1.0/servicelibrary-1.0.pom
2022-12-26 14:58:44.049 INFO/MobileBuild: - https://bin.pega.io/artifactory/repo2/com/example/servicelibrary/servicelibrary/1.0/servicelibrary-1.0.pom
2022-12-26 14:58:44.050 INFO/MobileBuild: Required by:
2022-12-26 14:58:44.051 INFO/MobileBuild: project :app > com.****.***:****-release:0.1-SNAPSHOT:20221226.092417-1
2022-12-26 14:58:44.052 INFO/MobileBuild: * Try:
2022-12-26 14:58:44.053 INFO/MobileBuild: > Run with --stacktrace option to get the stack trace.
2022-12-26 14:58:44.054 INFO/MobileBuild: > Run with --info or --debug option to get more log output.
2022-12-26 14:58:44.055 INFO/MobileBuild: > Run with --scan to get full insights.
2022-12-26 14:58:44.056 INFO/MobileBuild: * Get more help at https://help.gradle.org
2022-12-26 14:58:44.057 INFO/MobileBuild: BUILD FAILED in 1m 24s
2022-12-26 14:58:44.058 INFO/MobileBuild: Execution failed for task ':customize'.
Module build.gradle.kts file dependencies and plugins defined like below.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.android.library")
kotlin("android")
id("gradle-pega-android-module")
id("maven-publish")
}
group = "com.****.******"
version = "0.1-SNAPSHOT"
android {
compileSdk = 33
defaultConfig {
minSdk = 23
targetSdk = 33
consumerProguardFiles("proguard-rules.pro")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.4.1")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0-alpha06")
testImplementation("junit:junit:4.12")
implementation("com.google.mlkit:image-labeling:17.0.7")
implementation("com.google.android.gms:play-services-mlkit-text-recognition:18.0.2")
implementation("com.google.android.gms:play-services-mlkit-image-labeling:16.0.8")
implementation("com.example.servicelibrary:servicelibrary:1.0") /** AAR dependency **/
}
As per logs looks like PIMC is looking for AAR which we created. Is there any way that when we package the module get all the dependencies of other AAR's in the module itself or does PIMC provides any Remote Repository for us to load aar files?
Thanks
Pegasystems Inc.
PL
@SSrinivas AAR dependencies from the module should be picked up automatically and bundled with the module. If you take a look at the output of "packageModule" task (which is then used as input to "uploadModule") you could notice it's an archive containing maven-like repo structure. Basically, what happens is that the module plugin looks for any AAR dependencies that are not publicly available (mavenCentral(), google() etc) and adds them to the pacakge from your local cache.
file:/opt/customizer/build/customize/repository/com/example/servicelibrary/servicelibrary/1.0/servicelibrary-1.0.pom this is actually the path that the file should end up at when building from the mobile channel. Something must have changed recently either in Gradle or Android Gradle Plugin because it seems that it stopped working and the dependencies are not bundled. I would have to take a look a bit deeper to figure out what's wrong
Updated: 29 Dec 2022 8:28 EST
Coforge
IN
@gabir Thanks for the response, can you please help us on this to know what the exact root cause that AAR is not bundled.
We have already raised an INC (INC-253484), to know why the AAR is not bundled as part of the Package.
We are using devkit version 8.8.300
@cherb FYI.
Thanks
Updated: 30 Dec 2022 2:08 EST
Pegasystems Inc.
PL
@SSrinivas Ok, it DOES work, though I guess I just forgot how and we could use a bit of documentation for that. The dependencies will be packaged if they come from external maven repositories defined in the module. So any repository that is not mavenCentral, jcenter or google. The Artificatory configuration you mention in the INC is for internal use - we build most of the stuff with our own caches.
One of the solution to your problem is to create a local repo or even use default Maven Local and publish your AAR dependency there. After that, just add a similar block to the module
maven { url = uri("file://home/<user>/.m2/repository/") }
So that the dependency is picked from there. After that, packaging the module should include resolved dependencies along with their transitive ones.
Keep in mind that though the line above basically is the equivalent of "mavenLocal()", dependencies won't be bundled if you define it that way.
Updated: 29 Dec 2022 10:16 EST
Coforge
IN
@gabir , we have done the changes as suggested, but we are getting the same error while we build from the channel, not sure anything we missed or not kept the snippet at right place.
AAR is available in local.
We have added the given snippet in the module build.gradle.kts (custom module top-level gradle file)
When we package the module the file size remains.
Below is the build.gradle.kts file.
@gabir , we have done the changes as suggested, but we are getting the same error while we build from the channel, not sure anything we missed or not kept the snippet at right place.
AAR is available in local.
We have added the given snippet in the module build.gradle.kts (custom module top-level gradle file)
When we package the module the file size remains.
Below is the build.gradle.kts file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
val agpVersion: String by project
val repositoryUrl = "file:${rootProject.projectDir.absolutePath}/repository"
repositories {
maven(url = repositoryUrl)
mavenLocal()
google()
mavenCentral()
maven {
url = uri("file://home/*******/.m2/repository/")
}
}
dependencies {
val pmcModuleVersion: String by project
val kotlinVersion: String by project
classpath("com.android.tools.build:gradle:$agpVersion")
classpath(kotlin("gradle-plugin", version = "$kotlinVersion"))
classpath("com.pega.gradle.plugins:gradle-pega-android-module:$pmcModuleVersion")
}
}
allprojects {
val repositoryUrl = "file:${rootProject.projectDir.absolutePath}/repository"
buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
maven(url = repositoryUrl)
maven {
url = uri("file://home/*******/.m2/repository/")
}
}
}
repositories {
mavenLocal()
google()
mavenCentral()
maven(url = repositoryUrl)
maven {
url = uri("file://home/*******/.m2/repository/")
}
}
}
tasks {
val clean by registering(Delete::class) {
delete(builder)
}
}
Thanks
Pegasystems Inc.
PL
@SSrinivas `/home/...` is a path specific to Linux based systems. For Windows you have to use a correct path to your .m2 directory, so probably
file:///c:/Users/<USER_NAME>/.m2/repository/
(or with \ instead of /, but java usually doesn't care about that)
Coforge
IN
@gabir I have tried the path in the below ways still remains the same issue. Any inputs further would be helpful.
Method 1
maven {
url = uri("file:///c:/Users/*********/.m2/repository/")
}
Method 2
maven {
url = uri("file:\\C:\\Users\\************\\.m2\\repository\\")
}
Thanks
Accepted Solution
Updated: 6 Feb 2023 6:44 EST
Pegasystems Inc.
PL
@SSrinivas I just noticed that the build.gradle.kts you posted above is the top level one. The repository has to be defined in the MODULE's build.gradle.kts similar to the below (full module gradle that I just checked)
@SSrinivas I just noticed that the build.gradle.kts you posted above is the top level one. The repository has to be defined in the MODULE's build.gradle.kts similar to the below (full module gradle that I just checked)
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.android.library")
kotlin("android")
id("gradle-pega-android-module")
}
group = "com.pega.testmodule"
version = "0.1-SNAPSHOT"
repositories {
maven {
url = uri("file://home/<USER>>/.m2/repository/")
}
}
android {
compileSdk = 33
defaultConfig {
minSdk = 23
targetSdk = 33
consumerProguardFiles("proguard-rules.pro")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.pega.mobile:vehicle-damage-reporting:0.3")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
testImplementation("junit:junit:4.12")
}
com.pega.mobile:vehicle-damage-reporting:0.3 is an AAR I deployed in my .m2 as maven artifact and this is (part of) the output of `packageModule`:
vehicle-damage-reporting is the AAR itself and vehicle-damage-modeling is a transitive dependency of the former.
-
Srinivas Sarda
Updated: 30 Dec 2022 9:05 EST
Coforge
IN
Thanks @gabir this helps to bundle the AAR with the package module and now the build is successful.
But Downloading in Progress task remains as it is, I have waited for 30+ mins still in the channel I see Downloading in progress. I tried 5 times still no luck.
When I trace from Pega I see from pzUpdateBuildStatus activity the status is coming as DOWNLOADING.
What could be the reason, it's remains in this task for a very long time and I don't see even after waiting long it moving to the completed state.
Any inputs please.
Thanks
Pegasystems Inc.
PL
@SSrinivas Must be a communication issue between the build server and mobile channel (timeout perhaps?). Another team would have to look into that. I'll ping them
-
Srinivas Sarda
Updated: 2 Jan 2023 2:07 EST
Coforge
IN
@gabir , Even I suspect timeout considering the size of APK 150+MB. But if this resolves, it will help us to test the things of custom module from actual app.
Thanks
Pegasystems Inc.
PL
@SSrinivasAre you using an on prem environment? I got this information:
User reports that build stuck at 'downloading in progress'
Such behaviour is related to configuration of e.g. "on prem" environments. The issue with downloading is usually related to Out Of Memory Exception, please check Pega logs. This issue is not related to downloading/building process but Pega Platform configuration (not enough memory).
-
Srinivas Sarda
Coforge
IN
@gabir , I don't see any logs related to a memory issue.
Interestingly, what I found this time was when we do build without the custom module download working, and then in the next attempt add the module and do the build download working
But in a scenario where the previously added module is deleted and just save the channel, and then add the new version module. In this case, build is getting stuck in the download.
Thanks