首页 > 解决方案 > 尝试使用 Firebase 在 Android Studio 中更新我的 build.gradle 并收到“AAPT2 错误:检查日志以获取详细信息”错误

问题描述

您好,我正在使用 Firebase 和 Android Studio 构建一个消息传递应用程序,但我的 build.gradle 文件遇到了问题。我试图更新我正在使用的 Firebase 版本,起初更新后我收到一条错误消息

“无法解决:com.google.firebase:firebase-core:16.0.1”

我发现了这个类似的帖子(Failed to resolve: com.google.firebase:firebase-core:16.0.1)并相应地更新了我的项目 build.gradle 文件和顶级构建 gradle 文件。

由于还遵循了响应中的建议,我重新运行了该应用程序,而我现在在构建控制台中收到“AAPT2 错误:检查日志以获取详细信息”错误。

我真的不知道如何提供解决方案,我已经花了几个小时尝试和浏览这个网站。任何帮助将不胜感激!

我正在关注的教程: https ://www.youtube.com/watch?v=5Y0foGqYmxc (大约 12:00)

build.gradle 文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.cmc.chatbox"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-beta01'

implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.android.support:support-v4:28.0.0-beta01'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.google.firebase:firebase-core:16.0.1'

implementation 'com.google.android.gms:play-services-auth:15.0.1'

//creates a rounded user profile image
implementation 'de.hdodenhof:circleimageview:2.2.0'

//ArthurHub - allows user to crop their profile image
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'

//Picasso - image uploader
implementation 'com.squareup.picasso:picasso:2.71828'

implementation 'com.firebaseui:firebase-ui-database:4.1.0'



}

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

顶级gradle文件:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.0.2'
  }
}

allprojects {
    repositories {
        google()
        jcenter()
  }
}

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

标签: androidfirebasegradle

解决方案


尝试android.enableAapt2=false添加gradle.properties


推荐阅读