首页 > 解决方案 > “基本活动”、Android Studio 3.1.4、API 28、Ubuntu 16.04 中的渲染问题

问题描述

当我尝试构建具有“基本活动”屏幕的 Android 应用程序时,我遇到了渲染问题。我尝试了所有可用的解决方案,但到目前为止没有任何帮助。

在“空白活动”的情况下,当我在 styles.xml 中将“Theme.AppCompat.Light.DarkActionBar”更改为“Basic.Theme.AppCompat.Light.DarkActionBar”时,渲染工作正常。但是当我使用“基本活动”时,这个技巧不起作用。以下是我的系统的配置:

以下是错误消息:

以下是我的 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'
}

请帮忙!

谢谢,桑杰·辛格

标签: androidandroid-studiorendering

解决方案


经过一番挣扎,我发现问题出在 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'
}

在此之后一切正常。


推荐阅读