Sorry to post yet another one of these, but it seems we have yet to document every solution to this issue.
Here’s what happened: I added a mapview, everything was working peachy. I added a slidingdrawer and moved buttons into it, then changed the root node from a linear to a relative. Since then I get an error in the Graphical Layout of my main.xml class that reads
Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed to find style ‘mapViewStyle’ in current theme.
Toggling the root node to linear and back to relative has gotten the map to display, but the error is still in the graphical layout.
So far I have done the following solutions, which may resolve the issue for most cases:
- Added a style.xml to create a ‘mapView’ style.
- Verified my build target is API 2.3.3 (10)
- Made sure
<uses-library android:name="com.google.android.maps"/>is a child node of Application.
- Clean/rebuilt my application.
- Deleted R.
- Deleted and rebuilt main.xml
- Restarted the adb server, Eclipse, my computer, and my device.
- Toggled between Android 3.0 and Android 2.3.3 in the Graphical Layout.
However, my problem persists. Here’s my layout xml.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mapview" style="@style/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:apiKey="asdf" //not my real key android:clickable="true" /> <!-- TODO: update the API key with release signature --> <SlidingDrawer android:id="@+id/slidingDrawer1" android:layout_width="match_parent" android:layout_height="match_parent" android:content="@+id/content" android:handle="@+id/handle" > <Button android:id="@+id/handle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Menu" /> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/about" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/about" /> <Button android:id="@+id/record" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/record" /> <Button android:id="@+id/start" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/start" /> </LinearLayout> </SlidingDrawer> </RelativeLayout>
Here is my manifest xml.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="edu.myschoolhere" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="com.google.android.maps"/> <activity android:name=".GeoTagActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
If anyone has a solution, please let me know. I’ll do my best to post back if I ever figure it out.
My answer may be a late one, but i hope that it’ll deals with the actual reason and sure it could be helpful for those who are going to search about the same problem in future.
This type of errors,
1. Android Google Maps Failed to find style 'mapViewStyle' in current theme 2. Failed to find style 'imageButtonStyle' in current theme 3. Failed to find style 'editTextStyle' in current theme 4. Failed to find style 'textViewStyle' in current theme
Anything from the above list it may be,
The ultimate reason is ,
We have selected the unavailable
Theme for the
This may cause because of,
- The selected
themeis not available in
- The selected
themeis belongs to higher version
sdk, but our current target
sdkis lower one.
This problem mostly happens,
- when you copy the whole
layoutfile and try to implement it in your
a. Your may forgot to copy
b. You may have lower
target sdk, the original
layoutcreated with higher
The Solutions for this problem are,
(Open and View the
layout file in the
Graphical Layout View, and look at the top Right corner.
themes for the
layout have been selected.)
- So click the dropdown list for
themeselection and choose the available
themesaccording to your project
targeted sdk themes.
- If the
customone , if you are required it , then copy the
themes.xmlfile to your project from the source where you copied the
- If the
theme, if you are required it , then change your
targetaccording to your selected
Hope,This might be helpful for somebody.
This solution is for Android Studio maybe it will give an idea for Eclipse user too.
Every android theme is not suitable for every view. Because of this we should select one of the suitable themes for our view type.
Here is how problems looks
If theme is not suitable it will give us missing styles error.
2.Select theme for your view
3.After selecting theme then press ok.
If the theme is suitable for your view it will render if not then select another theme and try until you find a suitable theme for your application.
Whenever your theme is suitable it will render as like the picure below.
I was facing a similar issue.
I don’t know what the problem was and after searching an answer on google I found nothing of help.
So What I did was deleted the activity and guess what??, it worked.
Again, I’m not sure how did this work out but it did eventually for me.
Hope this helps.
when you create android application,you choose minimum required sdk API14.And then,you will create project successfully.This is my solution.