2

I created this application using Google Maps Android v2 API. But now When I run the project i get the inflating class fragment error. I red most of the threads on stackoverflow but i couldnt find a solution. Any help is hugly appreciated. Thank you.

Here is my logcat Activity code and manifest:

11-10 13:58:01.179: E/Trace(1297): error opening trace file: No such file or directory (2)
11-10 13:58:01.868: W/dalvikvm(1297): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
11-10 13:58:01.950: E/AndroidRuntime(1297): FATAL EXCEPTION: main
11-10 13:58:01.950: E/AndroidRuntime(1297): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testmapv2/com.example.testmapv2.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.os.Looper.loop(Looper.java:137)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.ActivityThread.main(ActivityThread.java:5041)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at java.lang.reflect.Method.invokeNative(Native Method)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at java.lang.reflect.Method.invoke(Method.java:511)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at dalvik.system.NativeStart.main(Native Method)
11-10 13:58:01.950: E/AndroidRuntime(1297): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.Activity.setContentView(Activity.java:1881)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.example.testmapv2.MainActivity.onCreate(MainActivity.java:16)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.Activity.performCreate(Activity.java:5104)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
11-10 13:58:01.950: E/AndroidRuntime(1297):     ... 11 more
11-10 13:58:01.950: E/AndroidRuntime(1297): 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" />
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.dynamic.a.a(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
11-10 13:58:01.950: E/AndroidRuntime(1297):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-10 13:58:01.950: E/AndroidRuntime(1297):     ... 21 more

My Activity code is:

package com.example.testmapv2;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

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

public class MainActivity extends FragmentActivity {

    private GoogleMap map;

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

        map=((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    }
}

Here is my manifest file:

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <permission android:name="com.example.testmapv2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"></permission>
    <uses-permission android:name="com.example.testmapv2.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <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"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

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



    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testmapv2.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>
        <meta-data android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyC-ofuGcuvNqWX0gRz1yBqLdrrmC_rn84o"/>
    </application>

</manifest>
2
  • 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-d Commented Nov 10, 2013 at 14:15
  • what should i add there. i didt get you please help. Thank you Commented Nov 10, 2013 at 14:18

2 Answers 2

3

It seems that you should take use of the advice from your output:

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" />

You can read more about meta-data and application tags in Manifest.xml here: Manifest file meta-data

Sign up to request clarification or add additional context in comments.

7 Comments

I added code. but still it gets NullPointerException. here is the error 11-10 14:23:05.150: E/AndroidRuntime(1375): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testmapv2/com.example.testmapv2.MainActivity}: java.lang.NullPointerException . Please kindly help me.
could you please put your code here (of MainActivity) and log? You have NullPointer somewhere in the code but it is hard to tell where.
Sorry it looks like a mess. ill add it as a seperate question sir. Thanks for your help
I guess that your map object is Null and then you invoke setMapType(GoogleMap.MAP_TYPE_NORMAL); on it. try to do in in if(map!=null) setMapType(GoogleMap.MAP_TYPE_NORMAL);
It worked and now i get no errors. Thank you very much for your kind assistance. I now get update Google play services mesage on emulator. sir can you say that up to now if i attach a real phone will it work. Thank you again.
|
0

There is problem with your android configuration.

Refer https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2 link

and for refer abdroid Location service refer :

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.