android - 如何处理“在org.gradle.api.Project类型的项目':app'上找不到方法android()”的错误
问题描述
我收到以下错误ERROR: Could not find method android() for arguments [build_9fawur68cjcg5sfkvki95w8sr$_run_closure1@30cec325] on project ':app' of type org.gradle.api.Project.
我不确定为什么会出现此错误,并且我尝试了许多其他方法以查看是否可以使其正常工作。虽然它从来没有。
应用程序级别的 gradle 已多次修改,但都没有解决问题。项目级别的 gradle 也无法正常工作。
应用级分级
android {
compileSdkVersion 28
defaultConfig {
applicationId "net.troop59.LoginFirebase"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.6'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:28.0.0'
//add this line
compile 'com.google.firebase:firebase-auth:16.1.0'
}
apply plugin: "com.google.gms.google-services"
项目级gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
解决方案
推荐阅读
- select - 数据绑定点击事件不起作用
- gnuplot - gnuplot:事件直方图:timecolumn() 问题
- linux - 在 fzf 预览中使用 bat 突出显示行号
- laravel - 使用 Laravel 配置 Omnipay-stripe 以与 PCI SCA 一起使用
- python - 二维和一维 numpy 的笛卡尔积
- java - 在 Java 中使用“Sqlldr”获取异常无法运行程序“sqlldr”:CreateProcess error=2,系统找不到指定的文件
- scala - 貘, Circe, 图式
- google-api - 如何获取 Google Fit API 的用户 ID?
- javascript - Bootstrap 4 file input with bs-custom-file-input and Symfony 5 collection with dynamic upload fields
- perl - Perl 和契约式设计