Preview Android stopped working after update

Asked

Viewed 1,206 times

2

I work on an android project and, after updating to Android Studio 3.0, my project started to give problem.

Preview of my activities has stopped working, although the app is built and I can install it on mobile/emulator, I can’t see in real time the changes of the XML layout, follow error message:

Failed to load AppCompat ActionBar with unknown error.

also appeal to these mistakes:

- android.support.v7.widget.AppCompatImageView (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.RecyclerView (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.FloatingActionButton (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.AppCompatTextView (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)
- android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache)

From what I read about this link: here seems to be a problem in Gradle, I tried to restore from an earlier version of my versioning, but got no change, follow Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '26.0.2'

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    defaultConfig {
        applicationId "br.com.golfetto.golfettomobile"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "2017.11.07"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions { javaMaxHeapSize "4g" }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(path: ':componentsutils')
    compile group: 'com.google.guava', name: 'guava', version: 'r05'
    compile 'com.github.barteksc:android-pdf-viewer:2.5.1'
    compile group: 'commons-io', name: 'commons-io', version: '2.4'
    compile 'com.sackcentury:shinebutton:0.1.4'
    compile 'net.colindodd:toggleimagebutton:1.2'
    compile 'com.sackcentury:shinebutton:0.1.4'
    compile 'net.colindodd:toggleimagebutton:1.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'br.com.livroandroid:android-utils:1.0.2'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'com.synnapps:carouselview:0.0.9'
    compile 'se.emilsjolander:sprinkles:1.3.1'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.7.5'
    compile 'com.github.d-max:spots-dialog:0.4@aar'
    compile 'com.antonionicolaspina:revealtextview:2.0'
    compile 'com.jaredrummler:material-spinner:1.0.9'
    compile 'com.google.firebase:firebase-core:9.0.2'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'junit:junit:4.12'
    compile 'com.bcgdv.asia.lib:fanmenu:1.2'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.google.firebase:firebase-crash:9.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.github.chrisbanes:PhotoView:1.2.6'
    testCompile 'junit:junit:4.12'
}

EDIT: already tried to change the project theme, here is my Theme in XML

<style name="AppTheme" parent="Base.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>

who can help, thank you.

  • 1

    I have the same problem, I’ll follow that question, thanks.

  • 1

    I had a similar mistake and decided to change <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">&#xA;</style> for <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">&#xA;</style> in your Styles.xml file

  • @Zulian already tried to do that, it didn’t work either :(

  • 1

    And change their buildToolsVersion ? Maybe to 25

  • @Zulian then, I’m using Android Studio 3.0.0 and the minimum supported is version 26.0.2 (according to the error message that gave when I tried to do what you said)

  • 1

    Try updating the com.android.support:xxxxx for version 27.0.0

  • This video shows you how to solve this problem in 2 minutes: ----------------------------------------------------------------------------- https://www.youtube.com/watch?v=YnZaSL_QMPs&feature=youtu.be -----------------------------------------------------------------------------

Show 2 more comments

3 answers

2


In detriment to the little content in Portuguese of this subject and following the reply of ramaral I will post here the solution of the problem.

He suggested upgrading the libraries to version 27, but I used version 26 as the basis, and put both the compileSdkVersion as to the buildToolsVersion in the same version, follows code:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    defaultConfig {
        applicationId "br.com.golfetto.golfettomobile"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "2017.11.07"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions { javaMaxHeapSize "4g" }
}
dependencies {
    ...
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
}

2

The upgrade system does its job very well. Follow the instructions indicated by it and usually everything will be fine(in my case always ran).

Android Studio relies on other "tools" to work, namely the Build Tools and of Gradle plugin.

Different versions of Android Studio may require different versions of these "tools".

As I said before, the upgrade system ensures that they are properly updated when necessary, just follow the instructions.

However, there are times when, as far as the Layouts editor is concerned, it is necessary to update the support libraries. In this situation, you are not given this information during the update.

Open the module builde.Radle and change all lines compile 'com.android.support:xxx:24.2.0 for the latest version, which on this date is 27.0.0.

As a "golden rule" have, whenever possible, the support libraries, the Build Tools the Gradle plugin updated to the latest version.

Notes for version 3.1.

  • Any occurrence of compile, testCompile, debugCompile or realeseComplile will generate warnings and in the future(end 2018) cannot be used. You must replace them with implementation, testImplementation, debugImplementation and realeseImplementation, respectively.

  • It is no longer necessary to indicate the buildToolsVersion, it is automatically inferred. You should therefore delete it.

0

Thank you!

Solution for Gradle version 28 syronization problem! Hello worked the same strategy for version 28, passing to version 27! Thank you!

Name of xml file is "build Gradle(Module:app)

  • apply plugin: 'com.android.application'

    android { compileSdkVersion 27

    defaultConfig {

       applicationId "br.com.giovani.detectarv1"
    
       minSdkVersion 15
    
       targetSdkVersion 27
    
       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:27.1.1'

   implementation 'com.android.support.constraint:constraint-layout:1.1.3'

   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' }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.