instead of preview, Android Studio showing only black screen with 'android…ActionBarOverlayLayout' written on it

折月煮酒 提交于 2019-12-29 06:47:08

问题


From few days, I'm not able to see preview/design of screens/layouts. Only a black screen is shown with android...ActionBarOverlayLayout written on it.

There is no error or exception in logcat. Also after running the project no issue on device. Only preview and Design tab in Android Studio showing black screen.

This is happening for every layouts after some Android Studio and build tools updates(which happened automatically)

Note: If I change Theme in preview (Theme in Editor), then sometimes the preview is shown, but it's very weird preview which can't be used for development


回答1:


Got this error-message:

Error:Execution failed for task ':app:processDebugManifest'.
Suggestion: use a compatible library with a minSdk of at most 9, 
or increase this project's minSdk version to at least 14. 

The solution is (as everyone said before) to match up the versions:

compileSdkVersion 26
buildToolsVersion '26.0.2'
targetSdkVersion 26
compile "com.android.support:support-v4:26.0.2"
compile "com.android.support:design:26.0.2"

But also change the compatible library minSDK

minSdkVersion 14

And the play-services

compile 'com.google.android.gms:play-services:11.8.0'



回答2:


If problem still not solved after doing things that @Roar RAP mentioned.

Goto: src -> main -> res -> style.xml and add Base. to the style tag parent attribute. It should look like below,

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
...
</style>

This option is also worked for me.




回答3:


Had the same error as you.

I updated the build.grade file, so that the "compileSdkVersion" matched the version I was running in my emulator. I also updated my "targetSdkVersion" to likewise fit the SDK I was running in my emulator.

Lastly, Android Studio asked me to update the dependencies (underlined with red in the program, so that it matches the targetsdkversion.. the last three lines...)

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.example.android.miwok"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:27.0.1'
    compile 'com.android.support:support-v4:27.0.1'
    compile 'com.android.support:design:27.0.1'
}`



回答4:


You have to do two things:

  1. be sure to have imported right appcompat-v7 library in your project structure → dependencies
  2. change the theme in the preview window to not an AppCompat theme. Try with Holo.light or Holo.dark for example.



回答5:


Make sure your your app->bulid.gradle file have same verison with compileSdkVersion, buildToolsVersion, targetSdkVersion and support libraries notice the support libraries verison which in this example 23. If I have 26.0.2 buildToolsVersion I will change my support libraries version 26 too.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
defaultConfig {
    applicationId "com.example.android.miwok"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:design:23.3.0'
}



回答6:


Go to File → Invalidate/Cache Restart your studio this will help you.




回答7:


On the Preview tab, change the "AppTheme" to AppTheme.NoActionBar AppTheme.NoActionBar



来源:https://stackoverflow.com/questions/47049177/instead-of-preview-android-studio-showing-only-black-screen-with-android-act

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!