This my code:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
Inside onCreate() method:(I have only this at onCreate(), aside a bundle creation and variables asignation, using that bundle.)
FragmentManager myFM = getSupportFragmentManager();
SupportMapFragment myMAPF =(SupportMapFragment)myFM.
findFragmentById(R.id.mapfragment);
map=myMAPF.getMap();//Exception at this line
Layout:
<fragment
android:id="@+id/mapfragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
Manifest:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="myapikey" />
I have to mention that when i generated the api key I copied the debug.keystore file and stored in a more convenient location, and then generated it. I did it again with the original file in the original location, and returned the same SH1, however, so I didnt generated another API key. Have activated the interruptor in the API Access page.
I have seen some answer asking the same thing before, and I have tried a lot of their solutions... without luck.
I am running the app on a device with Android version 4.0, via USB, from Eclipse.
Anyone can help me to find where is the error? Thank you.
EDIT
Sorry, forgot the StackTrace
10-23 13:54:53.230: E/AndroidRuntime(6786): java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/mypackage.MapActivity}: java.lang.NullPointerException
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.os.Handler.dispatchMessage(Handler.java:99)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.os.Looper.loop(Looper.java:137)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-23 13:54:53.230: E/AndroidRuntime(6786): at java.lang.reflect.Method.invokeNative(Native Method)
10-23 13:54:53.230: E/AndroidRuntime(6786): at java.lang.reflect.Method.invoke(Method.java:511)
10-23 13:54:53.230: E/AndroidRuntime(6786): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
10-23 13:54:53.230: E/AndroidRuntime(6786): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
10-23 13:54:53.230: E/AndroidRuntime(6786): at dalvik.system.NativeStart.main(Native Method)
10-23 13:54:53.230: E/AndroidRuntime(6786): Caused by: java.lang.NullPointerException
10-23 13:54:53.230: E/AndroidRuntime(6786): at mypackage.MapActivity.onCreate(MapActivity.java:73)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.Activity.performCreate(Activity.java:4470)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-23 13:54:53.230: E/AndroidRuntime(6786): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
I just noticed a strange thing, in the first line of the stacktrace puts twice the full package of my app...why is this happening?