1

I am trying to make a simple map and debugging it in an emulator. I was wondering where is my mistake and how can I correct it.

Here is: Logcat:

12-12 15:32:28.310: D/dalvikvm(879): Not late-enabling CheckJNI (already on)
12-12 15:32:30.070: D/AndroidRuntime(879): Shutting down VM
12-12 15:32:30.070: W/dalvikvm(879): threadid=1: thread exiting with uncaught exception (group=0xb3abdb90)
12-12 15:32:30.150: E/AndroidRuntime(879): FATAL EXCEPTION: main
12-12 15:32:30.150: E/AndroidRuntime(879): Process: com.exemple.mysecondapp, PID: 879
12-12 15:32:30.150: E/AndroidRuntime(879): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exemple.mysecondapp/com.exemple.mysecondapp.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.os.Handler.dispatchMessage(Handler.java:102)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.os.Looper.loop(Looper.java:137)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.ActivityThread.main(ActivityThread.java:4998)
12-12 15:32:30.150: E/AndroidRuntime(879):  at java.lang.reflect.Method.invokeNative(Native Method)
12-12 15:32:30.150: E/AndroidRuntime(879):  at java.lang.reflect.Method.invoke(Method.java:515)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-12 15:32:30.150: E/AndroidRuntime(879):  at dalvik.system.NativeStart.main(Native Method)
12-12 15:32:30.150: E/AndroidRuntime(879): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.Activity.setContentView(Activity.java:1928)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.exemple.mysecondapp.MainActivity.onCreate(MainActivity.java:21)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.Activity.performCreate(Activity.java:5243)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-12 15:32:30.150: E/AndroidRuntime(879):  ... 11 more
12-12 15:32:30.150: E/AndroidRuntime(879): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.dynamic.a.a(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-12 15:32:30.150: E/AndroidRuntime(879):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-12 15:32:30.150: E/AndroidRuntime(879):  ... 20 more
12-12 15:34:25.171: I/Process(879): Sending signal. PID: 879 SIG: 9

Main class:

package com.exemple.mysecondapp;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;


public class MainActivity extends FragmentActivity {
    private GoogleMap gm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

        if (status == ConnectionResult.SUCCESS) {
            SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        }
        else {
            int requestCode = 10;
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
            dialog.show();
        }
    }

}

activity_main.xml:

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

app manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exemple.mysecondapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="12"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.exemple.mysecondapp.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>
    <uses-library android:required="true" android:name="com.google.android.maps" />


    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AN API KEY"/>
    </application>    
<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />


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

<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="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-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

I passed many hours on this and to date no valid answer. Thank you to anyone who answers this question.

io_v
  • 28
  • 1
  • 6
  • See http://stackoverflow.com/questions/19723811/after-google-play-service-update-to-version-13-i-got-an-error – laalto Dec 12 '13 at 21:20
  • Ok, I found the error. The meta-data is not at the right place in the code above. – io_v Dec 13 '13 at 01:48

1 Answers1

1
The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.

You should install google play services in emulator (based on Android 4.2.2 or higher)

http://developer.android.com/google/play-services/setup.html

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • I did that. The second meta-data was not in the right place. Now I get the Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above. Which I do not understand since I put it in there. Plus it should be supported by the AVD. – io_v Dec 13 '13 at 01:49