gpt4 book ai didi

android - "Failed to apply plugin ' com.android.internal.application"

转载 作者:行者123 更新时间:2023-12-04 13:29:26 35 4
gpt4 key购买 nike

我第一次在android studio上使用flutter,安装后我一直收到这个错误
我的 Gradle 文件版本是 4.1.0

Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\ahmed\flutter12\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Could not create plugin of type 'AppPlugin'.
> Could not generate a decorated class for type AppPlugin.
> com/google/wireless/android/sdk/stats/GradleBuildProject$PluginType

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
我的安卓版本是 4.0.1
这是我的 build.gradle 文件我不知道出了什么问题
我将我的 jdk sdk 和 android studio 更新到最新版本 4.1.2
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 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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutterwq"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

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 '../..'
}

最佳答案

打开 android/build.gradle 文件,查看 com.android.tools.build:gradle 的版本:

buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
...
}
}
使该版本更小,直到某些版本有效。
可以从这里选择版本,在插件栏中:
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
当 gradle 太旧并且 android gradle 插件太新时会出现问题。

关于android - "Failed to apply plugin ' com.android.internal.application",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65978260/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com