22

When adding a google map view (I extended a MapView, used the xml editor to add it to the Activity, and added my google maps api key to the layout xml file manually)

My permissions allow Internet in the manifest file

What i'm wondering, is in the xml editor i get the error "Failed to find style 'mapViewStyle' in current theme" but i seem to have everything set up correctly.

4
  • Can we see some code? The xml file.
    – user874649
    Aug 7, 2011 at 19:39
  • 5
    I am getting the same thing in Eclipse, but it's working. If you run the code you will see there's no problem. That error is because you haven't defined a style for googlemaps in values/styles.xml.
    – user874649
    Aug 7, 2011 at 19:46
  • 1
    like alex said it's an eclipse thing. For me this happens when I try to preview using android 3 or above.
    – Kevin Qiu
    Aug 7, 2011 at 21:25
  • see the answer here [Google Maps Failed to find style 'mapViewStyle' in current theme][1] [1]: stackoverflow.com/a/16975627/1979347 Jun 7, 2013 at 3:10

6 Answers 6

13

I had the same problem when I try to build a simple app, following the Android MapView tutorial.

The app showed this exception in AVD for the file file main.xml:

Failed to find style 'mapViewStyle' in current theme

At last I found that there is a mistake in file AndroidManifest.xml:

The element <uses-library android:name="com.google.android.maps" /> should be a child of the <application> element, not immediately within <manifest>.

Hope this was any help to you.

2
  • 9
    Sorry this is not the solution in my case. Jul 19, 2012 at 7:30
  • this is not a fix, I have it as child of the application element. Jul 9, 2014 at 9:32
4

For what its worth...

  1. My experience is that I got this in the UI Designer, but it did not break the build. I assume it is an Eclipse / Android SDK bug.

  2. My app has been working perfectly on the store until I upgraded my SDK to version 20. It leads me to believe this is something to do with the SDK.

  3. Of the various answers to this question (and duplicates) I found, none of them helped:

    • not changing the target SDK

    • not clean & build

    • not declaring a style manually


Finally, these questions are all duplicates (and mostly useless as confirmed by Ewok):

I tried to point this out to the moderators but I was ignored...

1
  • 2
    @ewoks +1 I totally agree - this was my attempt to get the moderators to combine these questions - they are all totally useless. Unfortunately when I flagged the question as duplicate, the moderator disagreed. Sep 28, 2012 at 17:29
2

I had the same issue when creating a Google Map view that worked well until I cleaned the project after placing a new icon.png in a drawable folder (Project >> Clean). Many times the cleaning process will install an import statement at the top program code, which overrides the R.java file in your project. The solution was to simply remove the following import statement:

import android.R

after the project was saved and rebuilt without issue.

2

I was having the same problem, and it turned out the problem was I had targeted the app towards the Google 4.0 APIs, but in the Manifest file specified Android API 10 (2.3.3).

Once I changed the project's target from 4.0 to 2.3.3 (API 10), it worked better.

2

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 layout.

This may cause because of,

  1. The selected theme is not available in themes.xml file.
  2. The selected theme is belongs to higher version sdk, but our current target sdk is lower one.

This problem mostly happens,

  1. when you copy the whole layout file and try to implement it in your project. a. Your may forgot to copy themes.xml file b. You may have lower target sdk, the original layout created with higher target sdk.

The Solutions for this problem are,

(Open and View the layout file in the Graphical Layout View, and look at the top Right corner. There your themes for the layout have been selected.)

  1. So click the dropdown list for theme selection and choose the available themes according to your project themes and targeted sdk themes. (OR)
  2. If the theme is a custom one , if you are required it , then copy the themes.xml file to your project from the source where you copied the layout xml file. (OR)
  3. If the theme is sdk avail theme, if you are required it , then change your target according to your selected theme.

Hope,This might be helpful for somebody.

1
-2

This is how I solved this problem. I had in my application google maps too, and I change:

c:\users\manuel\.Android\debug.keystore

with new created key (new key didn't work) and error was:

Failed to find style 'mapViewStyle' in current theme

after returning old key everithing worked fine. I really hate developing for android it's mess comparing to Visual studio development. this problem cost me 4h ...

To re-create debug.keystore use this "Debug certificate expired" error in Eclipse Android plugins

1
  • this could be related to maps api keys preventing possible the maps from working but is not related to the problem that the graphical view of the xml in the editor is broken but building works just fine. Jul 9, 2014 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.