我正在尝试在 android studio 中测试我的 ionic 应用程序。它抛出以下错误。
Gradle sync failed: Cause: compileSdkVersion is not specified.
有什么解决方案吗?我究竟做错了什么。
这是我的 build.gradle 文件
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
mavenCentral();
jcenter()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.1.0'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:+'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:+'
implementation 'com.android.support:appcompat-v7:27.+'
}
原文由 Amit Anand 发布,翻译遵循 CC BY-SA 4.0 许可协议
You are using android support library of
27.+
so you will have to givesdk
version27
ascompileSdkVersion
andtargetSdkVersion
否则您的项目不知道您的项目应该为哪个平台构建。这些参数应该在 build.gradle(app) 的 android 目录中给出:只需将此代码粘贴到下面
apply plugin: 'com.android.application'
这一行