我正在尝试将我的代码重构为 androidX。为此,android 要求我将编译版本更新为至少 28。因此,我将 bulid.gradle
中的编译版本更改为 compileSdkVersion 28
。
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
但是一旦我同步项目,我就无法下载平台插件,并且构建窗口中会显示以下错误。
Failed to find target with hash string 'android-28' in: /Users/work/Library/Android/sdk
最佳答案
你的编译版本应该是android-p。他们现在正在使用版本名称。
compileSdkVersion 'android-P'
目标应该只是 P
targetSdkVersion 'P'
参见here了解如何设置 Android P SDK。
编辑:
如果您收到错误/警告“minSdkVersion (21) 大于 targetSdkVersion (1)”,这是故意这样做的,请参阅 here .
由于 Android P 仍是预览版,因此 targetSdkVersion 中的“P”将作为版本 1 使用。一旦超出预览版,它将被替换为通常的 28。目前,要解决此问题,您需要提高minSdkVersion 也改为“P”。
关于android - 无法在 Android Studio 3.2 预览版中安装 android-28 的平台插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50719197/