android 使用Chaquopy插件后Gradle Sync无法正常工作

piok6c0g  于 2022-11-03  发布在  Android
关注(0)|答案(2)|浏览(230)

我正在尝试在我的android项目中使用Chaquopy插件。我的意思是,当一个flutter项目被创建时,它会生成一个android项目的应用文件夹。由于Chaquopy不提供对flutter的直接支持,所以我决定在flutter生成的android应用中使用这个插件。我逐行阅读了Chaquopy的文档,并尝试按照那里给出的所有说明操作。但我想我错过了一些东西,它现在显示错误,并没有下载Chaquopy插件。我给我的设置。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
e3bfsja2

e3bfsja21#

正如其他人所提到的,Gradle插件门户今天似乎遇到了一些问题。
由于Flutter生成的项目使用旧的buildscriptapply语法来应用Android插件,因此您可能应该遵循与Chaquopy插件相同的模式。这样,甚至不会涉及Gradle插件门户。请参阅此版本的Chaquopy文档以获取示例。
或者,您可以使用新的plugins语法继续应用Chaquopy插件,但也可以在settings.gradle的pluginManagement { repositories }块中包含mavenCentral。这样,您就可以在不依赖Gradle插件门户镜像的情况下访问该插件。

46qrfjad

46qrfjad2#

Jcenter已经崩溃了,我们不知道它会持续多久,因为没有关于它的博客或社交媒体帖子。
请在此处查看:https://status.bintray.com/

相关问题