Android 加载AppCompat ActionBar失败,出现未知错误?
build.gradle文件Android 加载AppCompat ActionBar失败,出现未知错误?,android,android-studio,gradle,android-gradle-plugin,Android,Android Studio,Gradle,Android Gradle Plugin,build.gradle文件 apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "io.dume.dume" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "io.dume.dume"
minSdkVersion 15
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
}
我刚刚创建了一个新项目,在activity_main.xml上发现了这个错误,我没有做任何更改。有什么解决办法吗?我也有同样的问题。这似乎是Android Studio的一个bug 在样式xml文件中,更改以下内容:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
为此:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
对我有效。我在YouTube上使用3种方法修复此错误
将目标sdk版本设置为27。 将编译sdk版本设置为27。 应用程序兼容版本从28.0.0-alpha3到27.1.1 如果您仍然想使用sdk版本28
只需将alpha3替换为alpha1,而无需更改任何其他内容这对我来说很有效当发生这种情况时,我不知道为什么它不能与28:
//use this instead
compileSdkVersion 27
buildToolsVersion '27.0.3'
targetSdkVersion 27
dependencies{
//switch to these
implementation 'com.android.support:appcompat-v7:27.0.0-alpha'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.0.0'
}
这对我有用
打开,res-->values-->styles.xml,在这里您会发现这样一行:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
将其更改为:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
换言之,将DarkActionBar更改为NoActionBar将Memo的compact版本28alpha降级为27可能与以下内容重复: