gpt4 book ai didi

android - 构建gradle导致应用生成错误

转载 作者:行者123 更新时间:2023-12-03 06:05:45 24 4
gpt4 key购买 nike

我正在使用Android Studio 1.4.1。当我在Android Studio中打开任何项目时,该项目的所有类均已正确加载,并且该项目运行正常。
问题是当我尝试操作名为“EcoAssistant_03”的特定项目时,我收到以下消息:

Error:(22, 0) Gradle DSL method not found: 'android()'
Possible causes:<ul><li>The project 'EcoAssistant_03' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

我不知道该项目有什么问题,我也不知道如何正确运行它。

请查看下面发布的build.gradle文件,并让我知道如何使其运行

build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.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
}

android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
}

build.gradle :
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.com.ecoassistant_03"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile files('libs/Jama-1.0.3.jar')
compile files('libs/drivingEfficiencyModuleRunnable_00_out.jar')
}

更新:

enter image description here

最佳答案

您的错误告诉您确切的问题。

Gradle DSL method not found: 'android()'



从顶层build.gradle中删除此 android部分。 Android插件尚未应用到该文件。
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
}

这样可以解决问题,但是这里有一些注意事项

这些行不是必需的。您已经在依赖项部分的第一行中对其进行了编译
compile files('libs/Jama-1.0.3.jar')
compile files('libs/drivingEfficiencyModuleRunnable_00_out.jar')

并且此行编译了紧随其后的两个行,因此也没有必要
compile 'com.android.support:design:23.1.1'

换句话说,这就是构建应用程序所需的全部
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.1.1'
}

关于android - 构建gradle导致应用生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38953328/

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