1

I am unsure of the errors that I am getting when I try to launch this app on a tablet. I have implemented all the correct permissions, meta-data and implemented the correct API key inside the manifest. I have also done everything needed inside the mainactivity and the layout. Please read the error log below and let me know whats happening, thank you in advance.

//error log

12-05 06:03:41.660: E/AndroidRuntime(3095): FATAL EXCEPTION: main
12-05 06:03:41.660: E/AndroidRuntime(3095): Process: com.example.googlemapapp, PID: 3095
12-05 06:03:41.660: E/AndroidRuntime(3095): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlemapapp/com.example.googlemapapp.MainActivity}: android.view.InflateException: Binary XML file line #78: Error inflating class fragment
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.os.Handler.dispatchMessage(Handler.java:102)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.os.Looper.loop(Looper.java:136)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.ActivityThread.main(ActivityThread.java:5026)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at java.lang.reflect.Method.invokeNative(Native Method)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at java.lang.reflect.Method.invoke(Method.java:515)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at dalvik.system.NativeStart.main(Native Method)
12-05 06:03:41.660: E/AndroidRuntime(3095): Caused by: android.view.InflateException: Binary XML file line #78: Error inflating class fragment
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.Activity.setContentView(Activity.java:1930)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.example.googlemapapp.MainActivity.onCreate(MainActivity.java:18)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.Activity.performCreate(Activity.java:5242)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
12-05 06:03:41.660: E/AndroidRuntime(3095):     ... 11 more
12-05 06:03:41.660: E/AndroidRuntime(3095): Caused by: java.lang.IllegalStateException: Unable to find dynamic class com.google.android.gms.maps.internal.CreatorImpl
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.internal.u.a(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.internal.u.U(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.internal.u.S(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.SupportMapFragment$b.mA(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.dynamic.a.a(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2158)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
12-05 06:03:41.660: E/AndroidRuntime(3095):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-05 06:03:41.660: E/AndroidRuntime(3095):     ... 21 more

//manifest

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="20" />

    <permission 
        android:name="com.example.googlemapapp.maps.permission.MAPS_RECIEVE"
        android:protectionLevel ="signature"/>

    <uses-permission android:name="com.example.googlemapapp.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"/>
    <!-- The following two permissions are not required to use
         Google Maps Android API v2, but are recommended. -->
    <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"/>


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


        <uses-library
        android:name="com.google.android.maps"
        android:required="false" /> 


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

        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="hidden" />

    </application>

</manifest>

//mainactivity.java

package com.example.googlemapapp;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;

public class MainActivity extends FragmentActivity {
EditText TXTA, TXTB;

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

        TXTA = (EditText) findViewById(R.id.editText1);
        TXTB = (EditText) findViewById(R.id.editText2);



    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

//mainactivity.xml

<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:background="#FFFFFF"
    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="com.example.googlemapapp.MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="46dp"
        android:src="@drawable/a" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_toRightOf="@+id/imageView1"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/editText2"
        android:layout_alignLeft="@+id/imageView1"
        android:src="@drawable/b" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/editText2"
        android:layout_below="@+id/button1"
        android:ems="10"
        android:inputType="textMultiLine" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_below="@+id/editText1"
        android:layout_marginTop="15dp"
        android:ems="10" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imageView1"
        android:text="Enter Data below"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/imageView2"
        android:layout_alignRight="@+id/editText3"
        android:layout_below="@+id/editText2"
        android:text="Search" />

  <fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/lineartab" />

</RelativeLayout>

//api settings API settings

//I've uploaded the entire project if anyone wants to download and help me figure this out

http://phototitan.net/by3tga2vshxv

2 Answers 2

2

Use the mapFragment element as below in the xml

  <fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/lineartab" />

Because the API version is beneath 11, SupportMapFragment is used instead of MapFragment.

enter image description here

You need to check the project properties:

  1. Does Google API's selected?
  2. Google play service lib project added?

Hope this helps.

6
  • thank you for the effort, I have made the above change but I am still getting the same errors. I will modify the log above. Dec 5, 2014 at 6:06
  • @ssj3goku878 still facing issue?
    – Maveňツ
    Dec 5, 2014 at 6:15
  • yes, I have added the element as you said and I still get errors, I updated the error log above with the errors i am getting with your code. Thanks Dec 5, 2014 at 6:17
  • Yup! Google API's is selected along with the google play services. Will update with an image if it'll let me post that. Dec 5, 2014 at 6:34
  • I've added an image of my settings so you can see what I have going on Dec 5, 2014 at 6:38
1
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/lineartab" />

You are usin Inner fragment I think that is the problem. Instead of using fragment You should use com.google.android.gms.maps.MapView and try.

3
  • thank you but its no good, I still get similar errors except with MapView instead of SupportMapFragment. Dec 5, 2014 at 15:30
  • 1
    You need to use this instead of <fragment />. <com.google.android.gms.maps.MapView android:id="@+id/frMap" android:layout_width="match_parent" android:layout_height="match_parent" />
    – Biswajit
    Dec 6, 2014 at 4:25
  • yes that is correct since I am using an SDK lower than 11. Dec 6, 2014 at 16:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.