在Android Studio 3.3.1中导入旧项目后出现错误

时间:2019-02-10 07:52:06

标签: android android-studio

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:23.3.0'
    implementation 'com.android.support:support-v4:23.3.0'
    implementation 'com.android.support:design:23.3.0'
}

enter image description here
(点击图片放大)

2 个答案:

答案 0 :(得分:1)

此错误是因为您的compileSdkVersion与支持库版本不同。该错误表明您的compileSdkVersion 28 ,因此要解决此问题,您的gradle中应包含以下内容:

android {
  compileSdkVersion 28
  buildToolsVersion '28.0.3'
   defaultConfig {
       applicationId "com.project.sample"
       minSdkVersion 16
       targetSdkVersion 28
       versionCode 1
       versionName "1.0"
       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}

最新的buildToolsVersion28.0.3,但您可以将其更改为自己的。它应该以{{1​​}}开头。

答案 1 :(得分:0)

这是因为SDK 28版本不如... 27稳定。

将编译版本和目标版本设置为27。

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.0'
   defaultConfig {
       applicationId "com.project.sample"
       minSdkVersion 16
       targetSdkVersion 27
       versionCode 1
       versionName "1.0"
       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
implementation 'com.android.support:design:27.0.0'
}