我正试着在我的Android项目中使用Chaquopy Plugin,它是用Ffltter生成的.我的意思是,当创建一个Ffltter项目时,它会生成一个带有它的Android项目应用程序文件夹.由于Chaquopy并不提供对Ffltter的直接支持,所以我决定在Fflats生成的Android应用程序中使用它.我一行一行地看了查克比的文件,并试图按照那里给出的所有说明进行操作.但我想我遗漏了一些东西,它现在显示错误,并且没有下载Chaquopy插件.下面是我的settings.gradle和其他Gradle文件.请帮帮我.我对编程非常陌生,这就是为什么我不太懂这些东西的原因 Here is the Chaquopy Documentation

这是我的设置.Gradle

include ':app'

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

这是我的项目级build.gradle

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
plugins {
    id 'com.chaquo.python' version '12.0.1' apply false
}


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

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

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

这是我的应用程序级build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

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

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

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

plugins {
    id 'com.chaquo.python'
}

android {
    compileSdkVersion flutter.compileSdkVersion

    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.pyflut"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        python {
            buildPython "C:/Users/super/AppData/Local/Programs/Python/Python310/python.exe"
            buildPython "C:/Users/super/AppData/Local/Programs/Python/Python310/python.exe", "-3.10"
        }
    }

    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
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

最后是我的错误

Build file 'F:\Pyflut\android\build.gradle' line: 14

Error resolving plugin [id: 'com.chaquo.python', version: '12.0.1', apply: false]
> Could not resolve all dependencies for configuration 'detachedConfiguration1'.
   > Could not determine artifacts for com.chaquo.python:com.chaquo.python.gradle.plugin:12.0.1
      > Could not get resource 'https://plugins.gradle.org/m2/com/chaquo/python/com.chaquo.python.gradle.plugin/12.0.1/com.chaquo.python.gradle.plugin-12.0.1.jar'.
         > Could not HEAD 'https://jcenter.bintray.com/com/chaquo/python/com.chaquo.python.gradle.plugin/12.0.1/com.chaquo.python.gradle.plugin-12.0.1.jar'.
            > Read timed out

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleException: Error resolving plugin [id: 'com.chaquo.python', version: '12.0.1', apply: false]
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:215)...... [Can not copy full error because of character limitaions sorry for that but if it needs then I will provide you that

推荐答案

正如其他人所提到的,Gradle插件门户网站今天似乎遇到了一些问题.

由于您的Ffltter生成的项目使用旧的buildscriptapply语法来应用Android插件,因此您可能应该对Chaquopy插件遵循相同的模式.这样一来,Gradle插件门户甚至不会参与进来.有关示例,请参阅this version个Chaquopy文档.

或者,您可以继续使用新的plugins语法来应用Chaquopy插件,但也可以在settings.gradle的pluginManagement { repositories }块中包含mavenCentral.这应该允许您在不依赖Gradle插件门户的镜像的情况下访问插件.有关示例,请参见here.

Flutter相关问答推荐

来自另一个屏幕的数据

类型int不是可迭代动态tmdbapi类型的子类型<>

如何等待抖动S定时器.定期取消?

如何使一个悬浮的appbar在flutter?

自定义ItemBuilderFlutter

更改BottomNavigationBar onTap?的大小

在Flutter 中更改扩展瓷砖的高度

Android Studio扩展控件上未加载Google map

Flutter Android Google Sign-in error:ApiException:10在确认软件包名称、SHA-1 fingerprint 和设置同意页面后出现异常

在带有 flutter 的 Native Android 中,EventChannel.EventSink 始终为 null

Firestore 不会取代 map

在 flutter 的列中使用 Expanded 时出现渲染 Flex 错误

使用 Flutter 和 Dio 将图像上传到 API

在 Flutter 中解码 BLE 设备负载

无法在 ListView (Flutter) 中限制 Card 的最大宽度

Flutter:为什么我的 listTile colored颜色 被容器 colored颜色 覆盖了?

SfCircularChart 周围的额外间距

如何在dart中编写多个条件?

Flutter Bloc Todo 示例 - 收听存储库中的单个 todo

Flutter Firebase 可以在真实设备上运行,而不是在 Android 模拟器上运行