简体   繁体   English

应用程序在模拟器上运行,但不在真实设备上运行

[英]Application runs on emulator but not in real device

I have developed an android application. 我已经开发了一个android应用程序。 After launching the app it show splash screen and the login and it perfetly works on emulator and on real device , but when i press skip option on device the application crashed but not in emulator. 启动应用程序后,它会显示启动屏幕和登录名,并且可以在模拟器实际 设备上正常运行 ,但是当我在设备上按“跳过”选项时,应用程序崩溃了,但在模拟器中却没有。 Here is logcat for error: 这是错误的logcat:

07-11 12:48:59.735: D/skia(4382): jpeg_decoder mode 1, config 6, w 640, h 1136, sample 

1, bsLength 142a5!!
07-11 12:49:01.589: D/libc-netbsd(4382): getaddrinfo: autolife.com.np get result from proxy >>
07-11 12:49:02.126: D/skia(4382): jpeg_decoder mode 1, config 6, w 640, h 1136, sample 1, bsLength f1ae!!
07-11 12:49:08.694: W/dalvikvm(4382): VFY: unable to resolve virtual method 62: Landroid/app/ActionBar;.setHomeAsUpIndicator (I)V
07-11 12:49:08.868: E/AndroidRuntime(4382): FATAL EXCEPTION: main
07-11 12:49:08.868: E/AndroidRuntime(4382): java.lang.NoSuchMethodError: android.app.ActionBar.setHomeAsUpIndicator
07-11 12:49:08.868: E/AndroidRuntime(4382):     at np.com.autolife.activity.BaseActivity.onCreate(BaseActivity.java:41)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at np.com.autolife.AutoLifeNepal.onCreate(AutoLifeNepal.java:33)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.Activity.performCreate(Activity.java:5122)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.ActivityThread.access$600(ActivityThread.java:162)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.os.Handler.dispatchMessage(Handler.java:107)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.os.Looper.loop(Looper.java:194)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at android.app.ActivityThread.main(ActivityThread.java:5371)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at java.lang.reflect.Method.invoke(Method.java:525)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
07-11 12:49:08.868: E/AndroidRuntime(4382):     at dalvik.system.NativeStart.main(Native Method)

Please anybody have already faced this problem? 请有人已经面临这个问题吗? Please help me find out the solution. 请帮助我找出解决方案。 Thanks in advance. 提前致谢。

In your stacktrace log you can se NoSuchMethodError - it means that system is not able to find following method: android.app.ActionBar.setHomeAsUpIndicator 在您的stacktrace日志中,您可以看到NoSuchMethodError-这意味着系统无法找到以下方法: android.app.ActionBar.setHomeAsUpIndicator

As mentioned in documentation: http://developer.android.com/reference/android/app/ActionBar.html#setHomeAsUpIndicator(android.graphics.drawable.Drawable) 如文档中所述: http : //developer.android.com/reference/android/app/ActionBar.html#setHomeAsUpIndicator(android.graphics.drawable.Drawable)

Don't know exactly which one you are trying to use, but both: 不确切知道您要使用哪一个,但是两者:

setHomeAsUpIndicator(Drawable)

and

setHomeAsUpIndicator(int)

were added in API level 18 . 已在API级别18中添加。 This means that they wont be available on lower API versions. 这意味着它们将在较低的API版本上不可用。 This is probably the reason for your issue - you are trying to execute this code on phone with lower API version (below JELLY_BEAN_MR2). 这可能是造成问题的原因-您正在尝试在API版本较低(低于JELLY_BEAN_MR2)的手机上执行此代码。

You have 2 options: 您有2个选择:

I . Check the API version before calling this method: 在调用此方法之前,请检查API版本:

if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.JELLY_BEAN_MR2) {
    actionBar.setHomeAsUpIndicator(int);
}

This will avoid crash, but won't take any effect on lower API versions - so you probably want to go with the second option to achieve your styling goals. 这样可以避免崩溃,但不会对较低的API版本产生任何影响-因此,您可能希望使用第二个选项来实现样式目标。


II . Instead of trying to set homeAsUpIndicator from code - you can do it safely from styles (because it is available from API 11 ) by adding "android:homeAsUpIndicator" attribute. 无需尝试通过代码设置homeAsUpIndicator-您可以通过添加“ android:homeAsUpIndicator”属性,从样式中安全地进行设置(因为它可以从API 11获得 )。 http://developer.android.com/reference/android/R.attr.html#homeAsUpIndicator http://developer.android.com/reference/android/R.attr.html#homeAsUpIndicator

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:homeAsUpIndicator">@drawable/my_home_as_up_indocator</item>
</style>

Greetings. 问候。

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

相关问题 Android应用程序可在模拟器上完美运行,但在真实设备上崩溃 - Android Application runs perfect on emulator but crashes on real device 应用程序在设备上运行,但在模拟器上崩溃? - Application runs on Device but crashes on Emulator? 应用程序最终在模拟器上运行,但不在设备上运行 - Application ultimately runs on Emulator but not on device 应用程序在模拟器上运行正常,但在真实设备上崩溃 - App runs fine on emulator, but crashes on real device 应用程序可以在模拟器上完美运行,但不能在真实设备上运行 - App runs perfect on emulator but not on real device 应用程序在模拟器上运行良好,但在设备上显示NoClassDefFoundError - Application runs fine on emulator but gives NoClassDefFoundError on device android应用程序在AVD中运行,但在实际设备中停止运行 - android application runs in AVD but stoppes in real device Google Maps应用程序可以在模拟器上运行,但不能在真实设备上运行 - Google Maps application works on emulator but not real device 应用程序可在模拟器上运行,但不能在真实设备上运行-浮点型 - Application works on emulator, but not on real device - float type Android应用程序可以在模拟器中正常运行,但不能在真实设备中运行? - Android application works fine in emulator but not in real device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM