Failed to resolve:com.android.support.appcompat-v7.29.问题及解决方法
我是一名Android的初学者,使用的Android版本为《第一行代码》(第二版)中提供的android-studio-bundle-145.3276617-windows.exe在进行创建第一个Android程序时,报了如下错误之后我上网搜索资料,查看了博主 https://blog.csdn.net/mhl18820672087/article/details/7838536...
我是一名Android的初学者,使用的Android版本为《第一行代码》(第二版)中提供的android-studio-bundle-145.3276617-windows.exe
在进行创建第一个Android程序时,报了如下错误
之后我上网搜索资料,查看了博主 https://blog.csdn.net/mhl18820672087/article/details/78385361的解决办法,并自己对着实行,并最终解决
出现上图这个问题是因为android studio SDK平台工具和项目构建工具(SDK Build-Tools)的版本不一致造成的,如下图所示,是我出现的问题
此处我的SDK Build-Tools工具版本为26.1.1,而平台为29,因此出现错误
所以我门需要使版本统一,通过修改下图中的build.gradle(Module:app)文件,可以实现两者版本一致
修改前的代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 29 // 使用版本29的SDK编译
buildToolsVersion "29.0.2" // 构建工具版本号为29.0.2 对应上图的SDK Build-Tools29
defaultConfig {
applicationId "com.example.helloworld"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:29.+' //这一行是远程依赖声明
testCompile 'junit:junit:4.12'
}
修改后的代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26 //修改
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.helloworld"
minSdkVersion 15
targetSdkVersion 26 //修改
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+' //修改
testCompile 'junit:junit:4.12'
}
但楼主修改完之后,仍出现了下列问题
这是提醒你需要安装这个缺少的平台,点击该链接,进行安装,待安装完后,再点击运行,这是编译不会报错,编译成功界面如下所示
程序会正确执行,执行效果如下所示
更多推荐
所有评论(0)