iam在eclipse上构建android应用程序,当我想在我的Android设备上运行该应用时,会显示以下消息: 不幸的是,testm已经停止了。
这是日志猫:
04-04 18:00:01.201: I/Process(28482): Sending signal. PID: 28482 SIG: 9
04-04 18:00:24.531: W/ApplicationPackageManager(28715): getCSCPackageItemText()
04-04 18:00:24.531: I/PersonaManager(28715): getPersonaService() name persona_policy
04-04 18:00:24.561: D/AndroidRuntime(28715): Shutting down VM
04-04 18:00:24.561: W/dalvikvm(28715): threadid=1: thread exiting with uncaught exception (group=0x4181bc08)
04-04 18:00:24.566: E/AndroidRuntime(28715): FATAL EXCEPTION: main
04-04 18:00:24.566: E/AndroidRuntime(28715): Process: com.example.testm, PID: 28715
04-04 18:00:24.566: E/AndroidRuntime(28715): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testm/com.example.testm.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.ActivityThread.access$900(ActivityThread.java:161)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.os.Handler.dispatchMessage(Handler.java:102)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.os.Looper.loop(Looper.java:157)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.ActivityThread.main(ActivityThread.java:5356)
04-04 18:00:24.566: E/AndroidRuntime(28715): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 18:00:24.566: E/AndroidRuntime(28715): at java.lang.reflect.Method.invoke(Method.java:515)
04-04 18:00:24.566: E/AndroidRuntime(28715): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
04-04 18:00:24.566: E/AndroidRuntime(28715): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
04-04 18:00:24.566: E/AndroidRuntime(28715): at dalvik.system.NativeStart.main(Native Method)
04-04 18:00:24.566: E/AndroidRuntime(28715): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
04-04 18:00:24.566: E/AndroidRuntime(28715): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:359)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Activity.setContentView(Activity.java:2015)
04-04 18:00:24.566: E/AndroidRuntime(28715): at com.example.testm.MainActivity.onCreate(MainActivity.java:15)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Activity.performCreate(Activity.java:5431)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
04-04 18:00:24.566: E/AndroidRuntime(28715): ... 11 more
04-04 18:00:24.566: E/AndroidRuntime(28715): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Fragment.instantiate(Fragment.java:597)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Fragment.instantiate(Fragment.java:561)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Activity.onCreateView(Activity.java:4969)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
04-04 18:00:24.566: E/AndroidRuntime(28715): ... 21 more
04-04 18:00:24.566: E/AndroidRuntime(28715): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/com.example.testm-9.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testm-9, /vendor/lib, /system/lib]]
04-04 18:00:24.566: E/AndroidRuntime(28715): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
04-04 18:00:24.566: E/AndroidRuntime(28715): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-04 18:00:24.566: E/AndroidRuntime(28715): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-04 18:00:24.566: E/AndroidRuntime(28715): at android.app.Fragment.instantiate(Fragment.java:583)
04-04 18:00:24.566: E/AndroidRuntime(28715): ... 24 more
和mainctivity.java:
package com.example.testm;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
@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;
}
@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);
}
}
和main_activity.xml:
<RelativeLayout
xmlns:andr oid="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="com.example.testm.MainActivity" >
<TextView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_below="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>