Md *_*sin 29 android android-studio android-gradle-plugin
我在导入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()
}
Run Code Online (Sandbox Code Playgroud)
我检查了使用gradle文件,但是在这个项目中得到了同样的错误.
小智 32
以上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
}
Run Code Online (Sandbox Code Playgroud)
在我的案例中,我的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
}
Run Code Online (Sandbox Code Playgroud)
按"再试一次"以同步gradle文件.这解决了我成功构建的问题.
niu*_*ius 19
尝试使用命令行运行gradlew tasks以查看构建失败的原因.
就我而言:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-27 Android SDK Platform 27
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
Run Code Online (Sandbox Code Playgroud)
所以我只是跑去Android\sdk\tools\bin接受许可证,然后在命令行中传递构建.
我认为Android Studio正在为错误的问题而烦恼.因此,您可以在命令行中检查实际输出并查找发生的情况.
| 归档时间: |
|
| 查看次数: |
24636 次 |
| 最近记录: |