0

I try to show google maps on my aplication but i can´t this is the errors

01-17 03:54:14.312: E/AndroidRuntime(1355): FATAL EXCEPTION: main
01-17 03:54:14.312: E/AndroidRuntime(1355): java.lang.NullPointerException
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.app.Activity.startActivityForResult(Activity.java:2827)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.app.Activity.startActivity(Activity.java:2933)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.view.View.performClick(View.java:2485)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.view.View$PerformClick.run(View.java:9080)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.os.Handler.handleCallback(Handler.java:587)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.os.Looper.loop(Looper.java:130)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at android.app.ActivityThread.main(ActivityThread.java:3683)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at java.lang.reflect.Method.invokeNative(Native Method)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at java.lang.reflect.Method.invoke(Method.java:507)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-17 03:54:14.312: E/AndroidRuntime(1355):     at dalvik.system.NativeStart.main(Native Method) 

manifest.xml I add all permisions that i found in internet and i thing that the problem its not here

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.flow"
        android:versionCode="1"
        android:versionName="1.0" >
        <uses-sdk
            android:minSdkVersion="4"
            android:targetSdkVersion="18" />
            <permission
                android:name="com.example.flow.permission.MAPS_RECEIVE"
                android:protectionLevel="signature" />
        <uses-feature
                android:glEsVersion="0x00020000"
                android:required="true"/> 
            <uses-permission android:name="com.example.flow.permission.MAPS_RECEIVE" />
            <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
            <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="android.permission.ACCESS_COARSE_LOCATION"/>
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.flow.Flow"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data
          android:name="com.google.android.maps.v2.API_KEY"
          android:value="AIzaSyDNIkpmmuFyj2vpTfAPtnqWpf-EX94bRl0"/>
    <meta-data
          android:name="com.google.android.gms.version"
          android:value="@integer/google_play_services_version" />
</application>

activity_flow.xml add fragment and SupportMapFragment

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Flow" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

<fragment 
          android:id="@+id/map1"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>

flow.java

 package com.example.flow;
import com.google.android.gms.maps.GoogleMap;
import android.os.Bundle;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;

public class Flow extends FragmentActivity {
    GoogleMap map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flow);    
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {    
    }
}

2 Answers2

0

I guess from this line at android.app.Activity.startActivityForResult(Activity.java:2827) you might have forget to implement onActivityResult method in your class. Make sure if you are starting activity as startActivityForResult() then you must have to implement this method.

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
  • thanks but i implemet you say this public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.flow, menu); return true; } – user3159679 Jan 17 '14 at 04:44
  • @user3159679 Please post your java code. This posted code is not sufficient. – GrIsHu Jan 17 '14 at 06:24
  • @user3159679 In your `Flow` you have not started any activity which returns the result back to your `Flow` activity that is why its throwing nullpointer exception. – GrIsHu Jan 18 '14 at 04:53
0

Make sure your manifest has

<permission
        android:name="com.example.flow.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
<uses-permission android:name="com.example.flow.permission.MAPS_RECEIVE"/>

Also make sure that you have your key (debug or release) set in the maps api console.

vinay Maneti
  • 1,447
  • 1
  • 23
  • 31
  • these permissions are not required. https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2 – Raghunandan Jan 17 '14 at 04:44
  • @user3159679 these two are no longer required you can check the docs – Raghunandan Jan 17 '14 at 04:48
  • Raghunandan thans bro i got it, some other idea i was try with some 10 tutorials i read the documentation of google maps apiv2 and i can´t show the map – user3159679 Jan 17 '14 at 05:01