Gradle同步失败:原因:未指定compileSdkVersion [英] Gradle sync failed: Cause: compileSdkVersion is not specified
问题描述
我正在尝试在android studio中测试我的离子应用程序.它抛出以下错误.
I am trying to test my ionic app in android studio. It is throwing the below error.
Gradle sync failed: Cause: compileSdkVersion is not specified.
对此有什么解决方案?我在做什么错了.
Any solution for this ? What am I doing wrong.
这是我的build.gradle文件
Here is my build.gradle file
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.+'
}
推荐答案
您正在使用27.+
的 android支持库,因此您必须提供sdk
版本27
作为targetSdkVersion
,否则您的项目不知道应针对哪个平台构建项目.这些参数应在 build.gradle(app)中的android目录中指定:
You are using android support library of 27.+
so you will have to give sdk
version 27
as compileSdkVersion
and targetSdkVersion
otherwise your project does not know for which platform your project should be built. These parameter should be given in android directory like this in build.gradle(app):
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.abc.test"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
只需将此代码粘贴在apply plugin: 'com.android.application'
此行下方
Just paste this code below apply plugin: 'com.android.application'
this line
这篇关于Gradle同步失败:原因:未指定compileSdkVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!