我正在製作一個簡單的音樂播放器應用程序。它已在我的模擬器上完美工作,但在將其安裝到我的設備後,它會給出 「應用程序MusicShare
(進程com.example.musicshare)意外停止。請再試一次」。Android應用程序在模擬器中工作正常,但不在實際設備中?
我的設備是Galaxy S2,我從bin文件夾中獲取了apk。我已經使用「導出W/O無符號鍵嘗試,它不能代替安裝這裏的清單:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.musicshare"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidBuildingMusicPlayerActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PlayListActivity" />
</application>
</manifest>
任何幫助將不勝感激謝謝
編輯:!
以下是我在logcat上調試設備後的錯誤日誌:
11-05 17:31:17.705: D/dalvikvm(6222): GC_EXTERNAL_ALLOC freed 44K, 53% free 2551K/5379K, external 0K/0K, paused 23ms
11-05 17:31:17.760: D/dalvikvm(6222): GC_EXTERNAL_ALLOC freed 11K, 53% free 2575K/5379K, external 466K/518K, paused 28ms
11-05 17:31:17.790: D/AndroidRuntime(6222): Shutting down VM
11-05 17:31:17.790: W/dalvikvm(6222): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
11-05 17:31:17.795: E/AndroidRuntime(6222): FATAL EXCEPTION: main
11-05 17:31:17.795: E/AndroidRuntime(6222): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.musicshare/com.example.musicshare.AndroidBuildingMusicPlayerActivity}: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.os.Looper.loop(Looper.java:123)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.ActivityThread.main(ActivityThread.java:3691)
11-05 17:31:17.795: E/AndroidRuntime(6222): at java.lang.reflect.Method.invokeNative(Native Method)
11-05 17:31:17.795: E/AndroidRuntime(6222): at java.lang.reflect.Method.invoke(Method.java:507)
11-05 17:31:17.795: E/AndroidRuntime(6222): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-05 17:31:17.795: E/AndroidRuntime(6222): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-05 17:31:17.795: E/AndroidRuntime(6222): at dalvik.system.NativeStart.main(Native Method)
11-05 17:31:17.795: E/AndroidRuntime(6222): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
11-05 17:31:17.795: E/AndroidRuntime(6222): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
11-05 17:31:17.795: E/AndroidRuntime(6222): at java.util.ArrayList.get(ArrayList.java:311)
11-05 17:31:17.795: E/AndroidRuntime(6222): at com.example.musicshare.AndroidBuildingMusicPlayerActivity.playSong(AndroidBuildingMusicPlayerActivity.java:273)
11-05 17:31:17.795: E/AndroidRuntime(6222): at com.example.musicshare.AndroidBuildingMusicPlayerActivity.onCreate(AndroidBuildingMusicPlayerActivity.java:80)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-05 17:31:17.795: E/AndroidRuntime(6222): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
11-05 17:31:17.795: E/AndroidRuntime(6222): ... 11 more
插上電源通過USB和獲得墜毀的logcat的日誌。這會讓你(或我們)走向正確的方向。 – Eric
您可以嘗試通過USB插入手機並使用手機運行應用程序(將您的設備設置爲目標)。然後在啓動你的應用程序(並崩潰)後,你的logcat區域將會登錄。請發佈這些消息(通常用紅色表示錯誤),以便我們分析它。 – PinoyCoder
檢查您的數據,也許他找不到模擬器上存在的目錄或媒體文件,但手機上不存在 – pleerock