Android studio 4.1 依赖问题
Android studio 4.1 dependencies issues
我正在使用 Android studio(语言是 java)开发一个 App 项目,我试图在 build.gradle 和 app.gradle 中注入 firebase 并得到了以下错误“插件 {} 脚本块中只允许调用 id(String) 方法”,我不知道如何解决这个问题。以下是 gradle 个文件的副本供您检查
Build.Gradle 应用
plugins {
id 'com.android.application'
android {
// ...
}
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.openingscreen"
minSdkVersion 16
targetSdkVersion 30
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:19.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firbase:firebase-auth:19.3.1 '
}
apply plugin: 'com.google.gms.google-services'
确保您在顶级 build.gradle 部分中添加了 google-services:4.3.5
。
The top-level build.gradle file, located in the root project
directory, defines build configurations that apply to all modules in
your project.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath 'com.google.gms:google-services:4.3.5' //this
}
}
然后纠正您的模块级别 build.gradle
部分。
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
然后转到 gradle-wrapper.properties
部分并确保您使用
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
最后清理-重建-Gradle
我正在使用 Android studio(语言是 java)开发一个 App 项目,我试图在 build.gradle 和 app.gradle 中注入 firebase 并得到了以下错误“插件 {} 脚本块中只允许调用 id(String) 方法”,我不知道如何解决这个问题。以下是 gradle 个文件的副本供您检查
Build.Gradle 应用
plugins {
id 'com.android.application'
android {
// ...
}
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.openingscreen"
minSdkVersion 16
targetSdkVersion 30
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:19.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firbase:firebase-auth:19.3.1 '
}
apply plugin: 'com.google.gms.google-services'
确保您在顶级 build.gradle 部分中添加了 google-services:4.3.5
。
The top-level build.gradle file, located in the root project directory, defines build configurations that apply to all modules in your project.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath 'com.google.gms:google-services:4.3.5' //this
}
}
然后纠正您的模块级别 build.gradle
部分。
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
然后转到 gradle-wrapper.properties
部分并确保您使用
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
最后清理-重建-Gradle