13

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. enter image description here

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

Luuklag
  • 3,897
  • 11
  • 38
  • 57
Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111
  • 1
    Please perform Invalidate/cache restart. – Mohammed Rampurawala Nov 01 '17 at 06:15
  • @mzeus.bolt I tried it, but no difference. It didn't help – Shirish Herwade Nov 01 '17 at 06:19
  • try this :First you have to Sync your project. Next, go to Build menu, and clic on the Clean Project. Finally, again, go to Build menu, and clic on the Rebuild option. – batsheva Nov 01 '17 at 06:21
  • @batsheva I tried the steps few times but it didn't help – Shirish Herwade Nov 01 '17 at 06:27
  • 1
    try to change your theme of the project and set a parent to the theme, sometimes in updates the theme has to be updated too – batsheva Nov 01 '17 at 06:29
  • @batsheva thanks for the suggestion, but even changing themes shows some weird layout, black-white type, and that too very different. But for now it's passable – Shirish Herwade Nov 01 '17 at 08:00
  • 1
    please update all dependency in build.gradle module:app to latest once, this will resolve your issue – Vishal Yadav Nov 01 '17 at 11:03
  • were you able to understand why this is happening? please post your findings in the Answers section. I need answer too. :) – user1506104 Nov 29 '17 at 12:19
  • @user1506104 I didn't find any reason or a perfect solution to this problem yet. But just a work-arround given by sanoop sandy answer(second point). And the sad thing is I have to change the theme for each and every layout and that too everytime I open the layout(i.e. close and reopen) :( – Shirish Herwade Nov 30 '17 at 06:48
  • Solution is very simple. Just remove all warning by changin/updating all version(compile/build etc) in build.gradle to make everything same(pointing to same version). Or just simply update everything to latest version. Mouse-Hover over the things will show you the latest version recommended. For more info see below @Steffo Dimfelt answer – Shirish Herwade Feb 26 '18 at 11:05
  • If you have added xml code manually, ensure that you havent misspelled anything; Correct: `android.support.constraint.ConstraintLayout` – Blasanka Dec 01 '19 at 14:44

8 Answers8

9

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.

Blasanka
  • 21,001
  • 12
  • 102
  • 104
  • I have tried all the solution here, and none worked except this one here! Excellent and easy fix, but I do not understand what or why this happens. – dcx86 May 19 '18 at 18:18
6

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'
}`
Roar RAP
  • 61
  • 3
5

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.
Vishal Yadav
  • 3,642
  • 3
  • 25
  • 42
sanoop sandy
  • 534
  • 3
  • 12
  • changing theme i tried already, it didn't solve the issue completely, though it's passable for now :). About appcompat-v7 I'm not sure how to check it's right or not; Can you plz explain a bit more? – Shirish Herwade Nov 01 '17 at 08:03
  • To use the class ActionBarOverlayLayout you need to include this in the dependencies section of build.gradle file: `compile 'com.android.support:design:24.1.1'` Please match the version accordingly – sanoop sandy Nov 01 '17 at 08:50
3

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'
}
Muhammed Ozdogan
  • 5,341
  • 8
  • 32
  • 53
3

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'
Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111
Steffo Dimfelt
  • 870
  • 12
  • 11
1

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

Vishal Yadav
  • 3,642
  • 3
  • 25
  • 42
1

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

0

This might be the issue with AppCompat library version or your style selection.

So, Open your style.xml file under res/values folder and verify that the AppTheme parent value is Base.Theme.AppCompat.Light.DarkActionBar if not then replace the value with Base Theme value like this,

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

If the issue still persists then make sure your app->bulid.gradle file contains same verison for compileSdkVersion, buildToolsVersion, targetSdkVersion and support libraries.

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"
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81