Reputation: 6485
I am having issue trying to use GoogleMapApi V2 with the same code that i use in other applications. All i want is to do StartActivity(MapActivityFragment); without errors
I have those permissions
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.egdigital.appetablissement.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.egdigital.appetablissemen" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<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" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="theApiKey" />
<activity
android:name="com.egdigital.appetablissement.ActivityGoogleMap"
android:configChanges="orientation"
android:label="@string/app_name" >
</activity>
The XML that contains the map support fragment : activity_maps
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
And this class to manage the map
public class ActivityGoogleMap extends SherlockFragmentActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
}
}
I have included ActionBarSherlock and googlePlayServices-lib as libraries
also included android-support-v4.jar as external jar and added it to dependencies
When i do StartActivity(MapActivityFragment) i get this big dirty error :
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.egdigital.appetablissement/com.egdigital.appetablissement.ActivityGoogleMap}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: /data/app/com.egdigital.appetablissement-1.apk
Upvotes: 0
Views: 347
Reputation: 11756
Looks like there is some bad formatting surrounding the <application>
and <meta-data>
elements in your AndroidManifest.xml
.
So, the following:
<application
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="theApiKey" />
<activity
android:name="com.egdigital.appetablissement.ActivityGoogleMap"
android:configChanges="orientation"
android:label="@string/app_name" >
</activity>
...should be changed to:
<application>
<activity
android:name="com.egdigital.appetablissement.ActivityGoogleMap"
android:configChanges="orientation"
android:label="@string/app_name" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="theApiKey">
</application>
The Android Maps API v2 docs: https://developers.google.com/maps/documentation/android/start#adding_the_api_key_to_your_application
...say:
In AndroidManifest.xml, add the [meta-data] element as a child of the element, by inserting it just before the closing tag
</application>
.
Upvotes: 1