gpt4 book ai didi

android - Android Studio 无法识别默认配置

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

在更新到 Android studio 3.1 时,出现此错误

Android Gradle 插件无法识别 SourceSet“defaultConfig”。也许你拼错了什么?

构建渐变

apply plugin: 'com.android.application'

buildscript {
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.1'
// classpath 'com.android.tools.build:gradle:2.3.3'
//classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
jcenter()

maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}


apply plugin: 'android'

dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.github.barteksc:android-pdf-viewer:2.7.0'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'

}

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
//buildToolsVersion "21.1.2"
// useLibrary 'org.apache.http.legacy'
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

defaultConfig {
applicationId "com.mpathway.xxxx"
minSdkVersion 14
targetSdkVersion 27
versionCode 2
versionName "2.0"
}
// Move the tests to tests/java, tests/res, etc...
// instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
}

apply plugin: 'com.google.gms.google-services'

我在编译时收到警告,即使我删除了 defaultconfig 并出错

有人可以帮我解决这个问题吗?让我知道用什么代替它谢谢

最佳答案

您有多个 defaultConfig 闭包。理想情况下,只有一个。

无论如何,defaultConfig 直接进入 android 闭包内部,而不是 sourceSets 闭包内部。

关于android - Android Studio 无法识别默认配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49540450/

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