I've been working on this app for almost a year now (senior project) when it just decided to break a few days ago. My application has been developed using Eclipse version 3.7.2 64bit targeting Froyo Android 2.2, using my Windows 7 64bit pc. So far I have tried:
- rearranging the uses-library tag in the manifest file
- rewriting the map xml file
- deleting the R.java file and refreshing
- placing the mapview element within a layout
- reinstalling eclipse and the android-sdk
- cleaning the project
- creating a style.xml file and referencing it
- deploying on a actual device
- reverting back to previous code
and possibly more...
My code is as follows: gmap.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0xMbgnc-el963gCdpl547hdkgXUILTskZr-T5uvg" // random key posted here
/>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.PubMe"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".PubMeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MappingActivity"
android:label="@string/app_name">
</activity>
</application>
</manifest>
I highly appreciate any help in advance.
You must include /path_to_android-sdk/extras/google/google_play_services/libproject/google-play-services_lib
Library as a external library into your project and also include this jar file /path_to_android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
.
beside those, you should have these permissions:
<uses-permission android:name="android.permission.INTERNET" />
**<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>**
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<permission
android:name="com.example.app.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.app.permission.MAPS_RECEIVE"/>
Try to add the above in your Manifest file.
I think com.google.android.maps.MapView is now obsoleted now i used com.google.android.gms.maps.MapView. Please check http://developer.android.com/reference/com/google/android/gms/maps/MapView.html for help and If you want to use MapFragment then go through http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/ Url.
I'd suggest to take a look at the Maps demo app. This comes bundle with the Google Play services lib, in your SDK manager just include the checkbox for Samples for Google Play Services. You then can find the project files @ <android-sdk>/extras/google-play-services/samples/maps
in your SDK directory.
these are the permissions you should have normally for a map v2
<permission
android:name="com.example.gmapsapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gmapsapp.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
and the api key is now used in manifest file with meta tag
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/apikey />
here I am including a xml file example of gmaps
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
来源:https://stackoverflow.com/questions/10303274/failed-to-find-style-mapviewstyle-error-persists