When creating a new project in Android Studio while using the latest updates and after adding compile com.android.support:appcompat-v7:22.1.0
to the dependencies still have this issue (which is solved if I'm using API 21
):
Exception Details java.lang.NoSuchFieldError: View_theme at android.support.v7.internal.widget.ViewUtils.themifyContext(ViewUtils.java:124) at android.support.v7.widget.Toolbar.(Toolbar.java:198) at android.support.v7.widget.Toolbar.(Toolbar.java:192) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at com.android.layoutlib.bridge.bars.BridgeActionBar.(BridgeActionBar.java:84) at com.android.layoutlib.bridge.bars.AppCompatActionBar.(AppCompatActionBar.java:56)
When i opened projects that was originally created with eclipse the rendering for API 22
worked great on Android Studio .
Can someone please explain this ?
Another issue that i encountered is that when upgrading the SDK it adds the Android M API and it called API 22 just as Android 5.1.1 which can also cause rendering issues . The solution is just to switch back to API 22 5.1.1 Hope it helps .
Update :
Doing a Build>Clean Project
or a gradle Sync Project
will solve the problem.
Old answer : According to 22.1 changelog (source) :
Lollipop added the ability to overwrite the theme at a view by view level by using the android:theme XML attribute - incredibly useful for things such as dark action bars on light activities. Now, AppCompat allows you to use android:theme for Toolbars (deprecating the app:theme used previously) and, even better, brings android:theme support to all views on API 11+ devices.
So i guess if you change app:theme to android:theme it will work.
In my case, solution was as simple as
@style
to the parent theme<style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
remove android.support.v7.widget.
from Toolbar
move from app:theme
to android:theme
<Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With