So basically when I sync my project with the gradle with the chaquopy. I am unable to declare the function
I am expecting that the gradle sync is successful and I am able to start working on the project as soon as possible.
this is my build.gradle.kts (:app) based off this gradle found in chaquopy's own github repository.
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.chaquo.python")
}
afterEvaluate {
val assetsSrcDir = "src/main/assets/source"
delete(assetsSrcDir)
mkdir(assetsSrcDir)
for (filename in listOf("python/chaquopy/mediaPipe/main.py",
"java/com/example/createzero/MainActivity.kt")) {
val srcFile = file("src/main/$filename")
if (! srcFile.exists()) {
throw GradleException("$srcFile does not exist")
}
copy {
from(srcFile)
into(assetsSrcDir)
}
}
}
android {
namespace = "com.example.createzero"
compileSdk = 34
defaultConfig {
applicationId = "com.example.createzero"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
// val plugins = buildscript.configurations.getByName("classpath")
// .resolvedConfiguration.resolvedArtifacts.map {
// it.moduleVersion.id
// }.filter {
// it.group == "com.chaquo.python" && it.name == "gradle"
// }
// if (plugins.size != 1) {
// throw GradleException("found ${plugins.size} Chaquopy plugins")
// }
// versionName = plugins[0].version
//
// val verParsed = versionName!!.split(".").map { it.toInt() }
// versionCode = verParsed[0] * 1000000 +
// verParsed[1] * 1000 +
// verParsed[2] * 10
ndk {
abiFilters += listOf(
"armeabi-v7a", "x86", "x86_64"
)
}
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
resourceConfigurations += "en"
}
buildTypes {
create("releaseMinify") {
initWith(getByName("release"))
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
lint {
disable += "ValidFragment"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
chaquopy {
defaultConfig {
// Android UI demo
pip {
install("Pygments==2.2.0") // Also used in Java API demo
}
staticProxy("chaquopy.demo.ui_demo")
// Python unit tests
pip {
// We use an old version of murmurhash (built from the Chaquopy branch
// `murmurhash-0`), because in newer versions, importing murmurhash
// automatically imports and extracts murmurhash/mrmr.so, which would
// complicate the tests.
install("murmurhash==0.28.0") // Requires chaquopy-libcxx
// Because we set pyc.src to false, we must test extractPackages via pip.
install("../../product/gradle-plugin/src/test/integration/data/" +
"ExtractPackages/change_1/app/extract_packages")
}
extractPackages("ep_bravo", "ep_charlie.one")
staticProxy("chaquopy.test.static_proxy.basic",
"chaquopy.test.static_proxy.header",
"chaquopy.test.static_proxy.method")
pyc {
// For testing bytecode compilation on device, and also to include test
// source code in stack traces.
src = false
// For testing bytecode compilation during build.
pip = true
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.activity:activity-compose:1.8.1")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
//splash
implementation("androidx.core:core-splashscreen:1.1.0-alpha02")
}
and this is the build.gradle.kts (project) file
plugins {
id("com.android.application") version "8.1.4" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
id("com.chaquo.python") version "14.0.2" apply false
}
The
chaquopy
syntax requires Chaquopy 15, which will be released in the next few days.Meanwhile, you can use a pre-release build by following the instructions here:
For more details, see the Chaquopy 15 documentation.