Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception raised during rendering: View android.support.v7.widget.Toolbar not created with the right context

I'm receiving this error message in the Android Preview Designer as "Rendering Problems". I'm using API 22 to render and migrating to the new API support v4:22.1+ and v7:22.1+.

Rendering Problems Exception raised during rendering: View android.support.v7.widget.Toolbar not created with the right context

Rendering Problems

Scenario:

  • Using Android Studio v1.2RC
  • Render API v22 (changing to 21 or 19 does not solve it)
  • Migrating ActivityBarActivity to AppCompatActivity
  • Compile section:

    compile 'com.android.support:support-v4:22.1.+' compile 'com.android.support:appcompat-v7:22.1.+'

  • Toolbar

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_height="?attr/actionBarSize" android:layout_width="match_parent" android:background="?attr/colorPrimary" android:elevation="4dp" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/Theme.AppCompat" />

like image 231
Juan Saravia Avatar asked Apr 25 '15 14:04

Juan Saravia


2 Answers

The error was caused because I had to remove in the Toolbar layout, the "app" section and change 'app:' by 'android:'.

Remove:

xmlns:app="http://schemas.android.com/apk/res-auto"

Replace:

app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/Theme.AppCompat"

For:

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:popupTheme="@style/Theme.AppCompat"

like image 73
Juan Saravia Avatar answered Nov 01 '22 03:11

Juan Saravia


I solved this problem by Downgrading API level from 22,21 to 20 as shows in below image

enter image description here

like image 3
IshRoid Avatar answered Nov 01 '22 04:11

IshRoid