【发布时间】:2018-07-07 08:33:18
【问题描述】:
com.google.android.material:material:1.0.0-alpha3 需要 28 的最低 sdk 版本,com.android.support.AppCompatActivity 使用 27。所以当我尝试运行程序时出现错误。
另外,在官方材料设计文档中,声明com.android.material 和com.android.support 不应该一起使用。
因此,当我删除 com.android.support.AppCompatActivity 时,编译器无法解析 AppCompatActivity。我该怎么办?
更新 我能够通过删除 com.google.android 来解决异常。出现错误,因为 com.google.android 不能与 com.android.support 一起使用。
但我现在收到此错误: 失败 [INSTALL_FAILED_OLDER_SDK:在 installPackageLI 期间解析失败:/data/app/vmdl714979868.tmp/base.apk(在二进制 XML 文件第 7 行):需要开发平台 P,但这是一个发布平台。]
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
minSdkVersion 21
targetSdkVersion 'P'
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
//implementation 'com.google.android.material:material:1.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
【问题讨论】: