简体   繁体   English

Android studio 4.1 依赖问题

[英]Android studio 4.1 dependencies issues

I am working on an App project using Android studio (language is java) and i tried to infuse the firebase in build.gradle and app.gradle and got the following error "only id(String) method calls allowed in plugins {} script block" and i am lost as to how to solve the issue. I am working on an App project using Android studio (language is java) and i tried to infuse the firebase in build.gradle and app.gradle and got the following error "only id(String) method calls allowed in plugins {} script block" and我不知道如何解决这个问题。 Below is a copy of gradle files for your inspection以下是 gradle 文件的副本供您检查

Build.Gradle App Build.Gradle App

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'

Make sure you added google-services:4.3.5 in your top level build.gradle section.确保您在顶级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.位于项目根目录中的顶级 build.gradle 文件定义了适用于项目中所有模块的构建配置。

 buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath 'com.google.gms:google-services:4.3.5' //this

       
    }
}

And then rectify your Module level build.gradle section.然后纠正您的模块级别build.gradle部分。

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

Then goto gradle-wrapper.properties section and make sure you using然后转到gradle-wrapper.properties部分并确保您使用

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

Finally Clean-Rebuild-Gradle最后清洁-重建-Gradle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM