评估项目“:app”时出现问题

Posted

技术标签:

【中文标题】评估项目“:app”时出现问题【英文标题】:Problem Occurred evaluating project ':app' 【发布时间】:2020-08-11 22:07:34 【问题描述】:

我已经使用 Flutter 在 VS Code 上创建了一个应用程序,并且在我开始准备构建应用程序之前没有遇到任何问题。我开始将包名称从“com.example.careona19”更改为“com.covid19rsa.app”,但随后开始出现此错误:

```Launching lib\main.dart on VOG L09 in debug mode...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\pkirby\development\careona19\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> Plugin with id 'com.covid19rsa.app' not found.

* 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 1m 16s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)```

Android 级 build.gradle:

```buildscript 
    ext.kotlin_version = '1.3.50'
    repositories 
        google()
        jcenter()
    

    dependencies 
        classpath 'com.android.tools.build:gradle:3.6.1'
        //classpath 'com.android.tools.build:gradle:3.5.0' - original
        //classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
    


allprojects 
    repositories 
        google()
        jcenter()
    


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.covid19rsa.app'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
//apply plugin: 'com.google.gms.google-services'

def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) 
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   

android 
    compileSdkVersion 28

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

    lintOptions 
        disable 'InvalidPackage'
    

    defaultConfig 
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.covid19rsa.app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    

    signingConfigs 
       release 
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       
   
   buildTypes 
       release 
           signingConfig signingConfigs.release
       
   


flutter 
    source '../..'


dependencies 
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    //implementation 'com.google.firebase:firebase-analytics:17.2.2'

apply plugin: 'com.google.gms.google-services'
```

我一直在尝试所有我能找到的解决方案,但似乎没有任何效果。我有什么明显的遗漏吗?

【问题讨论】:

在应用级gradle中,使用apply plugin: 'com.covid19rsa.app'而不是apply plugin: 'com.android.application' @MidhunMP - 更新后,我仍然收到错误:* 出了什么问题:。 > 无法应用插件 [id 'com.android.internal.version-check'] > 支持的最低 Gradle 版本为 5.6.4。当前版本是 5.6.2。如果使用 gradle 包装器,请尝试将 C:\Users\pkirby\development\careona19\android\gradle\wrapper\gradle-wrapper.properties 中的 distributionUrl 编辑为 gradle-5.6.4-all.zip 尝试更新你的 gradle 版本 @MidhunMP - 现在完美运行......谢天谢地,我快要流泪了。请在答案部分添加您的答案,以便我将其标记为正确答案。谢谢! 不客气。快乐编码!!! 【参考方案1】:

这一行的问题:

apply plugin: 'com.covid19rsa.app'

你必须使用:

apply plugin: 'com.android.application'

【讨论】:

以上是关于评估项目“:app”时出现问题的主要内容,如果未能解决你的问题,请参考以下文章

如何解决颤振中的 build.gradle 错误。如何解决此错误“评估项目 ':app' 时出现问题。> 格式错误的 \uxxxx 编码。”

评估项目“:firebase_auth”时出现问题

评估根项目“firebase_auth”时出现问题。 > 找不到 firebase_core FlutterFire 插件

评估指令时出现 Proguard 错误

Gradle 同步失败:评估设置时出现问题

Flutter 项目构建失败