简体   繁体   English

Android应用程序可以在模拟器中正常运行,但不能在真实设备中运行?

[英]Android application works fine in emulator but not in real device?

I'm making a simple Music Player application. 我正在制作一个简单的Music Player应用程序。 It already works perfectly on my emulator but after I install it on my device, it gives "The application MusicShare (process com.example.musicshare) has stopped unexpectedly. Please try again" . 它已经可以在我的模拟器上完美运行,但是在将其安装到设备上后,它显示“应用程序MusicShare (进程com.example.musicshare)意外停止。请重试”

My device is a Galaxy S2 and I got the apk by taking it from the bin folder. 我的设备是Galaxy S2,我从bin文件夹中获取了apk。 I have tried using "Export w/o unsigned key and it cannot be installed instead. Here's the manifest : 我尝试使用“不带未签名密钥的导出文件,而无法安装它。这是清单

<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>

Any help will be appreciated. 任何帮助将不胜感激。 Thanks! 谢谢!

EDIT: 编辑:

Here's the error log from logcat after I debugged it on the device: 这是我在设备上调试之后从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

@Pleerock is correct. @Pleerock是正确的。 Apparently it was the problem with the path. 显然这是路径问题。 It should be "/sdcard/media/audio/Music/". 它应该是“ / sdcard / media / audio / Music /”。 Thanks for the help. 谢谢您的帮助。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android应用程序可以在模拟器上正常运行,但不能在真实设备上运行 - Android Application works fine on emulator but not on a real device 我的Android应用程序无法在模拟器上访问Internet,但在真实设备上可以正常工作 - My android application not able to access internet on emulator but works fine on real device Android应用程式可在模拟器上正常运作,但在真实装置中当机 - Android app works fine in emulator but crashes in real device Flutter 电话身份验证在模拟器上工作正常,但在真实设备上不工作(Android) - Flutter Phone authentication works fine on emulator but not working on real device (Android) Android应用程序可在模拟器上正常运行,但在真实设备上崩溃 - Android Application works correctly on emulator but crashes on real device Android 应用程序在少数真实设备上崩溃,但在与真实设备具有相同 API 的模拟器上运行良好 - Android app crashes on few real devices but works fine on an emulator which has the same API as that of the real device Toast在实际设备上不起作用,但在模拟器上可以正常工作 - Toast doesn't works on real device but works fine on emulator android应用程序在模拟器上工作正常,但在实际设备上崩溃,并在android studio中出现以下错误,并附加了代码 - android app works fine on emulator but crashes on real device with following error in android studio the code is attached Google Maps应用程序可以在模拟器上运行,但不能在真实设备上运行 - Google Maps application works on emulator but not real device 应用程序可在模拟器上运行,但不能在真实设备上运行-浮点型 - Application works on emulator, but not on real device - float type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM