0

我正在制作一个简单的音乐播放器应用程序。它已经在我的模拟器上完美运行,但在我的设备上安装它后,它给出 “应用程序MusicShare(进程 com.example.musicshare)已意外停止。请重试”

我的设备是 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
4

2 回答 2

0

@Pleerock 是正确的。显然这是路径的问题。它应该是“/sdcard/media/audio/Music/”。谢谢您的帮助。

于 2012-11-05T10:53:16.297 回答
0

有时您需要导出整个项目并获取 .apk 文件并安装它

于 2014-03-04T14:13:18.147 回答