我不确定是什么导致这运行不正常,当我在我的 android 模拟器中运行应用程序时,它显示错误“不幸的是应用程序已停止”
感谢任何帮助。我的 logCat 错误看起来像这样
03-29 10:25:32.717: E/Trace(779): error opening trace file: No such file or directory (2)
03-29 10:25:32.907: E/AndroidRuntime(779): FATAL EXCEPTION: main
03-29 10:25:32.907: E/AndroidRuntime(779): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.parkingtracker/com.example.parkingtracker.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.parkingtracker.MainActivity" on path: /data/app/com.example.parkingtracker-1.apk
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.os.Handler.dispatchMessage(Handler.java:99)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.os.Looper.loop(Looper.java:137)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-29 10:25:32.907: E/AndroidRuntime(779): at java.lang.reflect.Method.invokeNative(Native Method)
03-29 10:25:32.907: E/AndroidRuntime(779): at java.lang.reflect.Method.invoke(Method.java:511)
03-29 10:25:32.907: E/AndroidRuntime(779): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-29 10:25:32.907: E/AndroidRuntime(779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-29 10:25:32.907: E/AndroidRuntime(779): at dalvik.system.NativeStart.main(Native Method)
03-29 10:25:32.907: E/AndroidRuntime(779): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.parkingtracker.MainActivity" on path: /data/app/com.example.parkingtracker-1.apk
03-29 10:25:32.907: E/AndroidRuntime(779): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-29 10:25:32.907: E/AndroidRuntime(779): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-29 10:25:32.907: E/AndroidRuntime(779): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-29 10:25:32.907: E/AndroidRuntime(779): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-29 10:25:32.907: E/AndroidRuntime(779): ... 11 more
我的 AndroidManifest.xml 看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.parkingtracker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.parkingtracker.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>
</application>
</manifest>