> 找不到参数的方法 chaquopy()

问题描述 投票:0回答:1

在 com.android.build.gradle.internal.dsl.BaseAppModuleExtension 类型的扩展“android”上找不到参数 [build_9l7x9frxjdbl4l0fxjllj0gef$_run_closure2$_closure10@569cd6d3] 的方法 chaquopy()。

不明白该怎么办。尝试在 flutter\dart 上构建我的项目,并在尝试构建时遇到此问题。没有 chaquopy 一切都好,但我需要在我的项目中使用 python 从互联网收集信息。

文件 - app/build.gradle

   id "com.android.application"
   id "kotlin-android"
   id "dev.flutter.flutter-gradle-plugin"
   id "com.chaquo.python"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
   localPropertiesFile.withReader('UTF-8') { reader ->
       localProperties.load(reader)
   }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
   flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
   flutterVersionName = '1.0'
}

android {
   namespace "com.example.slovar"
   compileSdkVersion 34
   ndkVersion "21.1.6352462"

   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }

   kotlinOptions {
       jvmTarget = '1.8'
   }

   sourceSets {
       main.java.srcDirs += 'src/main/kotlin'
   }

   defaultConfig {
       // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
       applicationId "com.example.slovar"
       // You can update the following values to match your application needs.
       // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
       minSdkVersion 21
       targetSdkVersion flutter.targetSdkVersion
       versionCode flutterVersionCode.toInteger()
       versionName flutterVersionName
       ndk {
           abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
       }
   }



   buildTypes {
       release {
           // TODO: Add your own signing config for the release build.
           // Signing with the debug keys for now, so `flutter run --release` works.
           signingConfig signingConfigs.debug
       }
   }
   chaquopy {
       defaultConfig {
           buildPython "C:/Users/Fedor/AppData/Local/Microsoft/WindowsApps/python.exe"
       }
   }
}


flutter {
   source '../..'
}

dependencies {
   classpath 'com.android.tools.build:gradle:7.2.0'
   classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   classpath "com.chaquo.python:gradle:12.0.0"
}    

文件 - android/build.gradle

    ext.kotlin_version = '1.8.20'
    repositories {
        google()
        mavenCentral()
        maven { url "https://chaquo.com/maven" }

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.chaquo.python:gradle:12.0.0"

    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
} ````   




android dart chaquopy
1个回答
0
投票

您当前拥有的是以下配置结构,该结构在任何版本的 Chaquopy 中均无效:

android {
    chaquopy {
        defaultConfig {
            buildPython ...

由于您使用的是 Chaquopy 12.0,因此您应该遵循 Chaquopy 12.0 的文档。在该版本中,正确的结构是:

android {
    defaultConfig {
        python {
            buildPython ...

或者在当前版本的Chaquopy中,推荐的结构是:

chaquopy {
    defaultConfig {
        buildPython ...
© www.soinside.com 2019 - 2024. All rights reserved.