Проблемы с файлом build.gradle при попытке интегрировать chaquopy в Android Studio JellyfishAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Проблемы с файлом build.gradle при попытке интегрировать chaquopy в Android Studio Jellyfish

Сообщение Anonymous »

Я пытаюсь интегрировать chaquopy в Android Studio Jellyfish, чтобы можно было использовать Python, но есть проблемы с файлом build.gradle.kts на уровне модуля, и я получаю эти ошибки при синхронизации файлов Gradle: >

Код: Выделить всё

Unable to load class 'com.android.build.api.variant.Variant'
com.android.build.api.variant.Variant

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Это мой файл build.gradle.kts верхнего уровня:

Код: Выделить всё

plugins {
id("com.chaquo.python") version "15.0.1" apply false
}
Это мой файл build.gradle.kts на уровне модуля:

Код: Выделить всё

plugins {
alias(libs.plugins.android.application)
id("com.chaquo.python")
}

android {
namespace = "com.example.pythontestwithjava"
compileSdk = 34

flavorDimensions += "pyVersion"
productFlavors {
create("py310") { dimension = "pyVersion" }
create("py311") { dimension = "pyVersion" }
}

defaultConfig {
applicationId = "com.example.pythontestwithjava"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

ndk {
// On Apple silicon, you can omit x86_64.
abiFilters += listOf("arm64-v8a", "x86_64")
}

python {
version "3.11"
pip {
// A requirement specifier, with or without a version number:
install "scipy"
install "requests==2.24.0"

// An sdist or wheel filename, relative to the project directory:
// install "MyPackage-1.2.3-py2.py3-none-any.whl"

// A directory containing a setup.py, relative to the project
// directory (must contain at least one slash):
//   install "./MyPackage"

// "-r"` followed by a requirements filename, relative to the
// project directory:
//    install "-r", "requirements.txt"
}
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding = true
}

}

chaquopy {
defaultConfig { }
productFlavors { }
sourceSets { }

productFlavors {
getByName("py310") { version = "3.10" }
getByName("py311") { version = "3.11" }
}
}

dependencies {

implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraintlayout)
implementation(libs.navigation.fragment)
implementation(libs.navigation.ui)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}
Мои конкретные ошибки (выделены красным в Android Studio) в файле build.gradle.kts на уровне модуля:

Код: Выделить всё

undefined reference: python
undefined reference: pip
undefined reference: install
Пожалуйста, дайте мне знать, как исправить эти ошибки. ТИА.

Подробнее здесь: https://stackoverflow.com/questions/784 ... -android-s
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»