0

I've seen dozens of similar problems but none have seemed to fix my issue. I have an app that uses google maps v2 (previously used v1). I imported google-play-services and android-support-v4, and created an activity that extended SupportFragment (also tried just fragment). I added all permissions and my key to the manifest, and created a fragment in my layout folder which defines the map. However, my app crashes every time I call setContentView on my fragment within my activity. I imported android.support.v4.app.FragmentActivity and android.support.v4.app.Fragment in this activity, but get an error trying to inflate the fragment. The logcat log is listed below. Thanks in advance!

public class ManualCheckInMapActivity extends android.support.v4.app.FragmentActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_fragment);
         }
}

<?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"             
        android:id="@+id/map"        
        android:layout_width="match_parent"        
        android:layout_height="match_parent" />
</LinearLayout>

FATAL EXCEPTION: main

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.safehouse.onguardianmobile/com.safehouse.onguardianmobile.ManualCheckInMapActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:582)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:200)
    at android.app.Activity.setContentView(Activity.java:1647)
    at com.safehouse.onguardianmobile.ManualCheckInMapActivity.onCreate(ManualCheckInMapActivity.java:40)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    ... 11 more
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
    at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
    at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.safehouse.onguardianmobile-2.apk]
    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
    ... 23 more

UPDATE: I tried cleaning the project, but now get this error. I'm still new at this, no maybe I did not add the libraries properly?

Errors occurred during the build.

Errors running builder 'Android Package Builder' on project 'google-play-services_lib'.
Problems encountered while deleting resources.
Could not delete 'C:\Users\Travis\workspace\google-play-services_lib\bin\google-play-services_lib.jar'.
Problems encountered while deleting files.
Could not delete: C:\workspace\google-play-services_lib\bin\google-play-services_lib.jar.
Problems encountered while deleting resources.
Could not delete 'C:\workspace\google-play-services_lib\bin\google-play-services_lib.jar'.
Problems encountered while deleting files.
Could not delete: C:\Users\Travis\workspace\google-play-services_lib\bin\google-play-services_lib.jar.
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
user1200083
  • 317
  • 1
  • 5
  • 13
  • 1
    seems to be a problem with build path. right click on your project goto properties. goto order export tab. make sure android private libraries is checked. clean and build – Raghunandan Jul 10 '13 at 18:44
  • For more on the preceding comment, see: http://stackoverflow.com/questions/16596969/libraries-do-not-get-added-to-apk-anymore-after-upgrade-to-adt-22/16596990#16596990 – CommonsWare Jul 10 '13 at 18:45
  • Raghunandan: I tried cleaning the project, but now get this error: – user1200083 Jul 10 '13 at 18:52
  • what's the error now? – Raghunandan Jul 10 '13 at 18:54
  • there is problem while building your project. i am not sure i can help further. – Raghunandan Jul 10 '13 at 18:55
  • @user1200083 search on so for similar posts here's one http://stackoverflow.com/questions/14455018/eclipse-android-errors-running-builder-android-pre-compiler-on-project – Raghunandan Jul 10 '13 at 18:58
  • from the activity where you are initialising your map, can you add the imports part and the map initialisation part – tony m Jul 11 '13 at 03:52

0 Answers0