24

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.

Rishabh Srivastava
  • 3,683
  • 2
  • 30
  • 58
MechaJDI
  • 259
  • 1
  • 6
  • Did you find a solution to this? I have tried all SO answers, like you, with nothing that has worked. – Ryan Jun 19 '12 at 19:28
  • I actually did find a solution to this shortly after. Seeing as it's been a while, I don't remember EXACLTY what I did but my current map xml code is as edited into the original post. Hope it helps. – MechaJDI Jun 27 '12 at 07:53
  • 5
    Post your answer *as an answer* not in the body of the *question*. – casperOne Sep 18 '12 at 14:33
  • see this answer http://stackoverflow.com/a/17209093/1979347 – Rohan Kandwal Jun 20 '13 at 08:48
  • Please check http://stackoverflow.com/questions/12023940/lets-solve-the-failed-to-find-style-mapviewstyle-in-current-theme-error#answer-13069524 and this link http://stackoverflow.com/questions/6975203/android-google-maps-failed-to-find-style-mapviewstyle-in-current-theme#answer-7266336 – Rohan Pawar Mar 08 '14 at 11:10

5 Answers5

1

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"/>

Sadegh
  • 2,669
  • 1
  • 23
  • 26
1
<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.

user2919740
  • 43
  • 1
  • 6
1

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.

Sudip
  • 87
  • 1
  • 7
1

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.

Jaison Brooks
  • 5,816
  • 7
  • 43
  • 79
1

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" />
snj
  • 184
  • 3
  • 13