android - “基本活动”、Android Studio 3.1.4、API 28、Ubuntu 16.04 中的渲染问题
问题描述
当我尝试构建具有“基本活动”屏幕的 Android 应用程序时,我遇到了渲染问题。我尝试了所有可用的解决方案,但到目前为止没有任何帮助。
在“空白活动”的情况下,当我在 styles.xml 中将“Theme.AppCompat.Light.DarkActionBar”更改为“Basic.Theme.AppCompat.Light.DarkActionBar”时,渲染工作正常。但是当我使用“基本活动”时,这个技巧不起作用。以下是我的系统的配置:
- Ubuntu 16.04
- 安卓工作室 3.1.4
- 安卓 API 28
以下是错误消息:
- 渲染问题 在当前主题中找不到样式“coordinatorLayoutStyle”提示:尝试刷新布局。
- 缺少样式 缺少样式。是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。
- 无法实例化一个或多个类 无法实例化 以下类: - android.support.design.widget.CoordinatorLayout(开放类,显示异常,清除缓存) - android.support.design.widget.AppBarLayout(开放类,显示异常,清除缓存)提示:在自定义视图中使用 View.isInEditMode() 可跳过代码或在 IDE 中显示示例数据。如果这是一个意外错误,您也可以尝试构建项目,然后手动刷新布局。异常详细信息 java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListene
以下是我的 styles.xml 文件:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
以下是我的 build.gradle(Module:app) 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.root.myfirstapplication"
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-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0-rc01'
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'
}
请帮忙!
谢谢,桑杰·辛格
解决方案
经过一番挣扎,我发现问题出在 API 28 上(仍然不稳定)。我在 build.gradle(Module:app) 文件中将 API 28 更改为 26,最终看起来像这样:
apply plugin: 'com.android.application'
android {
**compileSdkVersion 26**
defaultConfig {
applicationId "com.example.root.jiocollect"
minSdkVersion 21
**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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
**implementation 'com.android.support:appcompat-v7:26.1.0'**
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
**implementation 'com.android.support:design:26.1.0'**
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'
}
在此之后一切正常。
推荐阅读
- python - 如何在 Azure Data Studio 中显示 IPython Notebook Output (Pandas Data Frame) 的所有列?
- raspberry-pi - 如何使用 Raspberry Pi 编写 SD/mmc 程序
- web-component - connectedCallback 中的自定义 Web 组件设置属性
- rust - 在 Rust 中使用 iodbc
- python - 如何在光栅图像中绘制轮廓或形状的偏移量?
- forms - 如何在表单输入字段中保存或存储数据。在反应原生提交表单后
- r - 具有来自 {gtsummary} 的 tbl_uvregression() 函数的多元单变量 Cox 回归
- docker - 带有 Docker 的超集无法添加到外部 mysql 的连接
- typescript - 我们可以根据道具的形状构建打字稿类型吗?
- python - MacOS中的Python Tkinter checkbutton小部件:如何设置文本颜色