gpt4 book ai didi

Android Studio::Gradle 脚本错误 Android()

转载 作者:行者123 更新时间:2023-12-02 11:00:19 24 4
gpt4 key购买 nike

我在当前的 android 项目下使用以下脚本

// Top-level build file where you can add configuration options common to all sub-projects/modules.

android {
compileSdkVersion 11
buildToolsVersion "11.0"

defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 11
targetSdkVersion 11
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

但是后来发现这个错误信息。
This error

如何解决这个问题?

最佳答案

android block 应该在一个模块内 build.gradle包含 apply plugin: 'com.android.application' , 而不是在根目录 build.gradle文件。

例子:

build.gradle :

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}

模块 build.gradle (可能在 app 文件夹中):
apply plugin: 'com.android.application'


android {
compileSdkVersion 11
buildToolsVersion "11.0"

defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 11
targetSdkVersion 11
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

关于Android Studio::Gradle 脚本错误 Android(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43829737/

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