'Error when connecting Firebase to Android Studio [duplicate]
I am trying to learn how to create an Android application with Android Studio. My project is currently blank, the only page is MainActivity.java
. I created a project in Firebase and put the name (com.example.connect
), and I added the JSON file to the App location, but when I click connect, I get the following error:
(Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync)
How can I fix it?
Build Gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "RUVOLT"
include ':app'
Build Gradle Module
plugins {
id 'com.android.application'
id 'com.google.firebase.crashlytics'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.ruvolt"
minSdk 19
targetSdk 32
versionCode 1
versionName "1.0"
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
}
}
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation 'com.google.firebase:firebase-analytics:20.0.2'
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.firebase:firebase-crashlytics:18.2.6'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Solution 1:[1]
In your build.gradle
, apply these plugins and libraries for adding firebase:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
In your class path file, please verify that you entered these lines properly inside the dependencies
tag:
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
Also, make sure you have added the JSON file of Google under the app
section of the project file. For proper reference, go to the documentation.
Solution 2:[2]
Add the Google service plugin:
plugins { id 'com.android.application' id 'com.google.gms.google-services' id 'com.onesignal.androidsdk.onesignal-gradle-plugin' }
Also check the
build.gradle
project for the Google service dependencyclasspath 'com.google.gms:google-services:4.3.10'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Andrei |
Solution 2 |