简体   繁体   中英

Ubuntu 14.04 -Android Studio: The following classes could not be instantiated

I've started to delve into app development and I'm following some online tutorials and I've come across this rendering issue. Whenever I select any theme other than AppTheme.NoActionBar I get an error along the following lines.

The following classes could not be instantiated: - android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache) - android.support.design.widget.AppBarLayout (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE Exception Details

java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library. at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34) at android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:178) at android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:172) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) Copy stack to clipboard

Look over all the solutions suggested here from changing appTheme in Styles and changing things in the AndroidManifest but nothing seems to work. I'm still receiving rendering problems in my content main.

My Styles.xml:

<!-- 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" />

My AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

This is my default XMLs, but even the changes suggest had no avail. Its been around 2 months and I still haven't gotten past this...

Use something like Theme.AppCompat.Light.NoActionBar . You can set this in your styles.xml found in your resources, res/values/styles.xml .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM