簡體   English   中英

無法解析 Android 應用模塊的 Gradle 配置,連接到 Firebase 時

[英]Could not parse the Android Application Module's Gradle config ,While connecting to Firebase

我收到此錯誤,同時從 Android Studio 中的 firebase 助手將應用程序連接到 firebase。 錯誤消息 -無法解析 Android 應用模塊的 Gradle 配置。 解決 gradle 構建問題和/或重新同步。 我嘗試了 Stack overflow 中發布的所有解決方案,並觀看了許多你的視頻,甚至清除了 gradle 緩存並更新了 IDE。 即使我的 Gradle 構建文件中沒有錯誤或警告。

>build.gradle(應用程序)

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.project.PlacementInfo"
        minSdk 25
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildFeatures {
        dataBinding = true

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    compileSdkVersion 32
    buildToolsVersion '32.0.0'
}

dependencies {

    implementation 'com.google.android.gms:play-services-location:20.0.0'
    implementation 'com.google.firebase:firebase-analytics'
    implementation platform('com.google.firebase:firebase-bom:30.2.0')
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.firebase:firebase-database:20.0.5'
    testImplementation 'junit:junit:'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}

>build.gradle(項目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "com.android.tools.build:gradle:4.2.2"
        classpath 'com.google.gms:google-services:4.3.13'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

那么在這里你必須在 gradle 級別 1 中添加類路徑

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath "com.android.tools.build:gradle:4.1.2" classpath 'com.google.gms:google-services:4.3.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases" } } } task clean(type: Delete) { delete rootProject.buildDir }

那么你必須在 gradle 級別 2 中添加應用插件

以下依賴項

 plugins { id 'com.android.application' } android { compileSdkVersion 31 defaultConfig { applicationId "com.example.chatapp" minSdkVersion 23 targetSdkVersion 31 versionCode 1 versionName "1.0" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation platform('com.google.firebase:firebase-bom:29.2.1') implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-auth:21.0.1' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1' implementation 'com.android.support:multidex:1.0.3' implementation 'com.google.firebase:firebase-firestore:24.1.0' implementation 'com.google.firebase:firebase-storage:20.0.1' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.firebaseui:firebase-ui-firestore:6.2.1' implementation 'com.firebaseui:firebase-ui-database:8.0.0' implementation 'com.google.firebase:firebase-database:20.0.4' implementation 'com.google.firebase:firebase-messaging:23.0.5' implementation ('org.jitsi.react:jitsi-meet-sdk:3.10.2') { transitive = true } implementation 'com.android.volley:volley:1.2.0' implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } apply plugin: 'com.google.gms.google-services'

來源[這里]

Issue is resolved, removed this line testImplementation 'junit:junit:' from build.gradle (app) and also compressed the compile SDK from 32 to 31 and added this line android.suppressUnsupportedCompileSdk=32 in the gradle's properties(Project)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM