gpt4 book ai didi

android - 如何在同步 Gradle 时修复 android studio 中的 'Cannot invoke method buildTypes()' 错误?

转载 作者:搜寻专家 更新时间:2023-11-01 09:19:40 24 4
gpt4 key购买 nike

我记得我没有在我的 Gradle 中编辑任何东西,突然我意识到我不能再同步项目 Gradle,向我显示此错误:
错误:无法在空对象上调用方法 buildTypes()

我在 StackOverflow 中搜索了我的问题并找到了一些类似的问题,但没有一个对我有用

这是我的 Gradle :

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'


repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.myapp.test"
minSdkVersion 18
targetSdkVersion 27

//todo: change the versionCode and the versionName before upload in store
versionCode 22
versionName "2.4.0"
aaptOptions {
additionalParameters "--no-version-vectors"
}

} buildTypes {
release {

minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-core:17.0.1'

implementation fileTree(include: ['*.jar'], dir: 'libs')


implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.google.firebase:firebase-crash:16.2.1'
testImplementation 'junit:junit:4.12'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'agency.tango.android:material-intro-screen:0.0.5'
implementation ('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
implementation ('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
transitive = true
}
implementation ('com.crashlytics.sdk.android:crashlytics-ndk:2.0.4@aar') {
transitive = true
}

}
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}

我不知道如何修复它,所以我需要你的帮助。

最佳答案

buildTypes 语句移到下一行。

使用

} 
buildTypes {

代替

} buildTypes {

关于android - 如何在同步 Gradle 时修复 android studio 中的 'Cannot invoke method buildTypes()' 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57325207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com