1

我正在尝试在我的 Android 应用程序中使用 Python,我已经更新了应用程序和项目文件的 gradle 文件,如下所示:

build.gradle(:app) 文件看起来像这样

apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        applicationId "com.example.finalone"
        sourceSets{
        }
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        python{
            buildPython "/home/anaconda3/bin/python3.7"
            buildPython "py -3.7"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    // we should add .jar extension too for AAR files
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'org.tensorflow:tensorflow-android:1.4.0'
}

build.gradle(MyProject) 看起来像这样

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        maven { url "https://chaquo.com/maven" }
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
        //implementation'org.tensorflow:tensorflow-android:+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath "com.chaquo.python:gradle:7.0.2"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven{
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

当我尝试在手机中安装应用程序时,我不断收到此错误:

评估项目 ':app' 时出现问题。

无法应用插件 [id 'com.chaquo.python'] 没有这样的属性:类的 dslScope:> com.android.build.gradle.internal.api.DefaultAndroidSourceDirectorySet

有什么我遗漏的吗,我一直在使用这个网站的规则https://chaquo.com/chaquopy/doc/current/android.html

4

0 回答 0