简体   繁体   中英

Google map api v2 android

am trying to use the google map v2 on my android project. I have downloaded the latest 4.2 with google api support. It seems that it's the way I import the lib project because I get error if I import android.support.v4.app.FragmentActivity; - the package doesn't exist. Am using netbeans. When I run on my gingerbbread phone, import android.support.v4.app.FragmentActivity; - the package doesn't exist. Am using netbeans. When I run on my gingerbbread phone, import android.support.v4.app.FragmentActivity; - the package doesn't exist. Am using netbeans. When I run on my gingerbbread phone, I get error inflating MapFragment. I tried supportmapfragment - it doesn't work too. I tried android update lib-project --path /Users/Adrian/Desktop/mpestwhite/libs/google-play-services_lib but keep wanting me to specify targets Please advice on the steps.

xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
  android:name="com.google.android.gms.maps.MapFragment"/>

OR

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>

My activity:

public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.map);
 }

manifeat:

         <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyDmoeTnhtdQFggDZiJOkeSU46qxU1jPvb0"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>

Right Click on Project -> Android Tools -> Add support Library

add this library and try importing fragments and make sure minSdkVersion is 11. Hope it helps.

I think you forget to add the support Fragment library in your application. android-support-v4.jar .

To add this library in your application just follow below steps:

1) Right click on your project.
2) Goto Project->Android Tools-> Add support Library.
3) After selecting this option it will search for missing library and after searching will prompt you for installation in which you select install all option.
4) After selecting this option it will automatically add all the missing library in your application.

Hope it will work.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM