0

I'm trying to display google map on my android app when user click on a button. when I click the button the app stops.No error in the code. I believe I've done everything right 1-I got the API KEY

2-I added the Google_Play_Services_lib.jar to the dependencies folder

3-added extra support tool

4-included the permissions,my key to the manifest

5-added fragment to my xml layout fie for the map

please help I feel like I've read and watched every tutorial there is...nothing worked!

My Log:

03-10 20:27:10.057: I/Process(17287): Sending signal. PID: 17287 SIG: 9
03-10 20:27:15.072: D/libEGL(17688): loaded /vendor/lib/egl/libEGL_adreno.so
03-10 20:27:15.072: D/libEGL(17688): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
03-10 20:27:15.082: D/libEGL(17688): loaded /vendor/lib/egl/libGLESv2_adreno.so
03-10 20:27:15.082: I/Adreno-EGL(17688): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build:  (CL4169980)
03-10 20:27:15.082: I/Adreno-EGL(17688): OpenGL ES Shader Compiler Version: 17.01.10.SPL
03-10 20:27:15.082: I/Adreno-EGL(17688): Build Date: 09/26/13 Thu
03-10 20:27:15.082: I/Adreno-EGL(17688): Local Branch: 
03-10 20:27:15.082: I/Adreno-EGL(17688): Remote Branch: 
03-10 20:27:15.082: I/Adreno-EGL(17688): Local Patches: 
03-10 20:27:15.082: I/Adreno-EGL(17688): Reconstruct Branch: 
03-10 20:27:15.122: D/OpenGLRenderer(17688): Enabling debug mode 0
03-10 20:27:16.683: D/AndroidRuntime(17688): Shutting down VM
03-10 20:27:16.683: W/dalvikvm(17688): threadid=1: thread exiting with uncaught exception (group=0x41931898)
03-10 20:27:16.693: E/AndroidRuntime(17688): FATAL EXCEPTION: main
03-10 20:27:16.693: E/AndroidRuntime(17688): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newandroid/com.example.newandroid.Mymap}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-10 20:27:16.693: E/AndroidRuntime(17688):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
03-10 20:27:16.693: E/AndroidRuntime(17688):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-10 20:27:16.693: E/AndroidRuntime(17688):    at android.app.ActivityThread.access$700(ActivityThread.java:159)

My code for Mymap activity p

ackage com.example.newandroid;

import android.os.Bundle;
//import android.app.Activity;
import android.support.v4.app.FragmentActivity;

public class Mymap extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mymap);
    }
}

My layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

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

Manifest

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"      package="com.example.newandroid"
        android:versionCode="1"
        android:versionName="1.0" >

    <permission
            android:name="com.example.newandroid.permission.MAPS_RECEIVE"
            android:protectionLevel="signature" />
        <uses-permission android:name="com.example.newandroid.permission.MAPS_RECEIVE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <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_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />

            <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true"/>


        <application

            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity android:name="MainActivity">
             android:label="@string/app_name" >
            <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
                </activity>

            <activity
            android:name="com.example.newandroid.Mymap"
            android:label="@string/title_activity_mymap"
            android:parentActivityName="com.example.newandroid.MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.newandroid.MainActivity" />
                </activity>

                 <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyAq44a-wWB4W6muJJqZ1DMH-livYscbiyk"/>
        </application>

    </manifest>

this is the MainActivity where the button is ,when clicked it should start Mymap activity.this is Mainactivity code

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;


public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); 
        // TODO Auto-generated method stub
    }
    public void view_map(View view) {
        Intent intent = new Intent(this, Mymap.class);
        startActivity(intent);


        // Do something in response to button
    }
}
user3392377
  • 33
  • 1
  • 6

3 Answers3

0

have you tried to look at this SO post? seems like changing the xml to match your class name fixes most issues.

Google Maps V2 - Error inflating class Fragment

Community
  • 1
  • 1
reidisaki
  • 1,525
  • 16
  • 29
  • post your project.property file if you are using eclipse. – Yashdeep Patel Mar 11 '14 at 07:02
  • Thanks guys I'm still testing the solutions u posted...will let u know how it goes! – user3392377 Mar 11 '14 at 10:45
  • @reidisaki I'm using java ADT(the eclips in the bundle) that comes as part of the bundle. But before using the ADT((the eclips in the bundle) I used to use standard eclips.so when I open the either eclips or the Adt(the eclips icon in the bundle) I find my projects in the same work space whether i have created them using the standard eclips or the ADT that comes with the bundle.so in my case am I using eclips?cause u said post property file if u use eclips.If your answer is yes where can i find the property file? thanks bro. – user3392377 Mar 11 '14 at 10:51
  • @Yashdeep Patel `target=android-18 android.library.reference.1=../../Desktop/GPS project/adt-bundle-windows-x86_64-20131030/adt-bundle-windows-x86_64-20131030/sd‌​k/extras/google/google_play_services/libproject/google-play-services_lib` – user3392377 Mar 11 '14 at 12:03
  • tried the tricks suggested by the posts u shared guys.changed the target built ,inclused extra meda data tags.Not working! Do u think I should delete the Google play sevices lib project from my work space and re-import it? but I'm fraid that deleting it from the work space doesn't delete the .jar files(that were added when referenced th google sevoce ply) from my dependencies folder of my project,so that when I re-mport it again more error will ecour.What's the savest way to reimport and reference the google play lib? – user3392377 Mar 11 '14 at 12:10
  • Just tried deleting the google play serv lib from the work space and then added it,refrenced it as a library and added the android support lib but still same problem :( Do you guys think it could be a fragment issue? Please any suggestion would be appreciated! – user3392377 Mar 11 '14 at 14:10
  • try adding this inside your tag. i feel like you didn't post the entire logcat to show this error... – reidisaki Mar 11 '14 at 17:05
0

If you are targeting api level 8 and above then you can't use a simple Activity, you need to extend FragmentActivity.

I'm guessing this is the reason you have the inflating problem.

And you are missing this meta-data section in you manifest file:

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

place it next to your's api key meta-data section.

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • thx Emil I worked that out.it was an exception that I had to add. thanks a lot!But I have another problem if u could see it here http://stackoverflow.com/questions/22427805/sharing-google-maps-or-taking-screen-shot-of-android-phone – user3392377 Mar 15 '14 at 22:06
0

I did use Google Maps v2 API for android in my recent app development and I cannot even start to tell you how long it took to just have the map show up on the screen. I eventually got it working and I have the project on Github which you can look through and make sure to read through all the important files like Manifest and res/ folder;

Google Maps API (Android) v2 Fragment Issues

I hope it helps!

Eenvincible
  • 5,641
  • 2
  • 27
  • 46