[英]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.