gpt4 book ai didi

android - 模块 'app' 是一个没有构建变体的 Android 项目

转载 作者:IT老高 更新时间:2023-10-28 22:01:32 30 4
gpt4 key购买 nike

我在导入 android 项目时遇到以下错误。

错误:模块 'app' 是一个没有构建变体的 Android 项目,无法构建。 请修复 build.gradle 文件中的模块配置,然后重新同步项目。

Gradle 文件代码。

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
applicationId "com.djalel.android.bilal"
minSdkVersion 9
targetSdkVersion 25
versionCode 4
versionName "1.3"
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}

aaptOptions {
cruncherEnabled = false
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:25.3.1'
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.jakewharton.timber:timber:3.1.0'
}
repositories {
mavenCentral()
}

我也检查了工作的 gradle 文件,但在这个项目中遇到了同样的错误。

最佳答案

上面的 gradle 文件代码似乎很完美。可能它与 app/build.gradle (Module:app) 无关。只需在 Project 窗口中打开其他 build.gradle (Project:Android) 文件并验证您的 Android Studio 版本必须与您的相同。

我替换为:

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

在我的情况下,我的 Android Studio v3.0.1:

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

按“重试”以同步 gradle 文件。这解决了我成功构建的问题。

关于android - 模块 'app' 是一个没有构建变体的 Android 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49834961/

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