In my Eclipse I created a new application.
Just for testing purposes I put a Fragment
in XML and left the code unchanged. But still my application is crashing. I've tried help from other questions but everyone is doing something like switching tabs and changing navigation.
So far I just want an empty Map Fragment. Don't even want to show the Map yet.
Code
public class MainActivity extends FragmentActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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;
}
}
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: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=".MainActivity" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
LogCat
03-07 01:0
8:54.174: E/AndroidRuntime(6687): FATAL EXCEPTION: main
03-07 01:08:54.174: E/AndroidRuntime(6687): Process: com.example.testtt, PID: 6687
03-07 01:08:54.174: E/AndroidRuntime(6687): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testtt/com.example.testtt.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.ActivityThread.access$800(ActivityThread.java:139)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.os.Handler.dispatchMessage(Handler.java:102)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.os.Looper.loop(Looper.java:136)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.ActivityThread.main(ActivityThread.java:5105)
03-07 01:08:54.174: E/AndroidRuntime(6687): at java.lang.reflect.Method.invokeNative(Native Method)
03-07 01:08:54.174: E/AndroidRuntime(6687): at java.lang.reflect.Method.invoke(Method.java:515)
03-07 01:08:54.174: E/AndroidRuntime(6687): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
03-07 01:08:54.174: E/AndroidRuntime(6687): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
03-07 01:08:54.174: E/AndroidRuntime(6687): at dalvik.system.NativeStart.main(Native Method)
03-07 01:08:54.174: E/AndroidRuntime(6687): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-07 01:08:54.174: E/AndroidRuntime(6687): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:315)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Activity.setContentView(Activity.java:1973)
03-07 01:08:54.174: E/AndroidRuntime(6687): at com.example.testtt.MainActivity.onCreate(MainActivity.java:14)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Activity.performCreate(Activity.java:5275)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
03-07 01:08:54.174: E/AndroidRuntime(6687): ... 11 more
03-07 01:08:54.174: E/AndroidRuntime(6687): Caused by: android.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
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Fragment.instantiate(Fragment.java:597)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Fragment.instantiate(Fragment.java:561)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Activity.onCreateView(Activity.java:4822)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
03-07 01:08:54.174: E/AndroidRuntime(6687): ... 21 more
03-07 01:08:54.174: E/AndroidRuntime(6687): Caused by: java.lang.ClassNotFoundException: Didn''t find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.testtt-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testtt-2, /vendor/lib, /system/lib]]
03-07 01:08:54.174: E/AndroidRuntime(6687): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-07 01:08:54.174: E/AndroidRuntime(6687): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-07 01:08:54.174: E/AndroidRuntime(6687): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-07 01:08:54.174: E/AndroidRuntime(6687): at android.app.Fragment.instantiate(Fragment.java:583)
03-07 01:08:54.174: E/AndroidRuntime(6687): ... 24 more
It should at least show me the empty SupportMapFragment
when I run the app but it's crashing.