0

I know that there are many topics on StackOverFlow regarding this problem, however none of them could help me. I am doing a very basic application which I just want to display a MAP.

  • I Have imported the google-play-services_lib to my main project.
  • I have generated my API Key.

This is my AndroidManifest.xml file:

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

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

    <permission
        android:name="com.linkme2night.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.linkme2night.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <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-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="com.linkme2night.view.interactwithvenue.InteractWithVenueActivity"
            android:label="@string/app_name" >
        </activity>
        <activity
            android:name="com.linkme2night.view.openvenuesmap.OpenVenuesMapActivity"
            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="AIzaSyBJVHZJr1Q14fcvEHBkAUT1A_ZH4eQlnrI" />
    </application>

</manifest>

This is my Layout XML file:

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

This is my code:

public class OpenVenuesMapActivity extends FragmentActivity  {

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

I am running the application on my Sony XPeria J. I get the following Error generated by Loc Cat:

05-01 18:51:48.544: E/AndroidRuntime(10794): FATAL EXCEPTION: main
05-01 18:51:48.544: E/AndroidRuntime(10794): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.linkme2night/com.linkme2night.view.openvenuesmap.OpenVenuesMapActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2065)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2090)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.access$600(ActivityThread.java:136)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.os.Looper.loop(Looper.java:137)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.main(ActivityThread.java:4802)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.reflect.Method.invokeNative(Native Method)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.reflect.Method.invoke(Method.java:511)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:580)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at dalvik.system.NativeStart.main(Native Method)
05-01 18:51:48.544: E/AndroidRuntime(10794): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.Activity.setContentView(Activity.java:1869)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.linkme2night.view.openvenuesmap.OpenVenuesMapActivity.onCreate(OpenVenuesMapActivity.java:14)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.Activity.performCreate(Activity.java:5013)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2029)
05-01 18:51:48.544: E/AndroidRuntime(10794):    ... 11 more
05-01 18:51:48.544: E/AndroidRuntime(10794): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment : make sure class name exists, is public, and has an empty constructor that is public
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
05-01 18:51:48.544: E/AndroidRuntime(10794):    ... 20 more
05-01 18:51:48.544: E/AndroidRuntime(10794): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment 
05-01 18:51:48.544: E/AndroidRuntime(10794):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
05-01 18:51:48.544: E/AndroidRuntime(10794):    ... 23 more

This is what I get when I create the google-service-lib from existing code, located in my C:/Program Files/eclipse/SDKs/... , and then import it on my project:

error loading lib???

Does anyone one know What else can I be missing? I am starting to get desperated with this simple thing...

3
  • Did you import the google-play-services_lib project from the android-sdk folder? Also, I think you need to be using the Google API's, not Android 4.2.2... Commented May 1, 2013 at 17:13
  • @Kaleb The tutorials I've been following all refer to use Android and not Google API as Project Build Target Commented May 1, 2013 at 17:17
  • You are correct, it had not clicked that if you were using the servcies_lib you were obviously using Maps V2, not V1. Commented May 2, 2013 at 14:44

2 Answers 2

2

Your min sdk is 11. You will need to add support library for api versions below 12

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

Fragments were introduced in HoneyComb. So for backward compatibality you need add support library

 android:name="com.google.android.gms.maps.SupportMapFragment "

Since you din't add support library you got classcastexception

To add support library check the link below

http://developer.android.com/tools/extras/support-library.html

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

Comments

1

I Have imported the google-play-services_lib to my main project.

Not according to your stack trace. Your stack trace suggests that you manually modified your build path to include the JAR from the Play Services SDK, rather than attaching the Play Services SDK as an Android library project.

11 Comments

I've edited my question with new information, as well as I posted a new logcat. Could you please give it a look? Thank you very much
@filipehd copy the library project to your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse the workspace to import the library project. Now you can refer the same in your android project
@filipehd: The red X means that your reference to the library project is broken for some reason, such as it no longer exists at the specified location.
@filipehd try copying the library project to a different drive.
android:minSdkVersion="11" your min sdk 11 meaning you wish to support you app on devices that run api 11 to 17
|

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.