我刚用Android Studio开始了一个项目。我突然开始遇到布局预览问题。预览会正常渲染屏幕,但我会看到一个恼人的Rendering Problems
窗口,上面写着:
Rendering Problems The following classes could not be found:
- android.support.v7.internal.app.WindowDecorActionBar (Fix Build Path, Create Class)
Tip: Try to build the project.
当然,我尝试了很多东西。
知道问题可能是什么?
我的build.gradle
是:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "gr.asd.asdapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
答案 0 :(得分:0)
As suggested here
Change your theme to inherit from a Base Theme.
<style name="AppTheme" parent="Theme.AppCompat.Mpla.Mpla">
<!-- Customize your theme here. -->
</style>
with
<style name="AppTheme" parent="Base.Theme.AppCompat.Mpla.Mpla">
<!-- Customize your theme here. -->
</style>
Android Studio has a terrible out-of-the-box experience. But it used to be worse. A completely new project that was not using the latest API would yield Obsolete class errors and you had to replace Activity with AppCompatActivity to make it work
Having said that, if you target the latest API your problem will be gone but obviously that's not a solution :)