Android M中的应用程序崩溃

时间:2015-07-31 11:09:55

标签: android api actionbarsherlock

我的应用程序总能正常运行,但现在在新的Android M预览中崩溃我认为问题在于ActionBarSherlock。有人有同样的问题或者我知道如何解决它?

这是错误:

07-31 10:41:59.435: E/AndroidRuntime(4239): FATAL EXCEPTION: main
07-31 10:41:59.435: E/AndroidRuntime(4239): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.messaging.android/com.myapp.messaging.android.holo.messagelist.MainActivity}: java.lang.RuntimeException: java.lang.IllegalAccessException: java.lang.Class<org.holoeverywhere.addon.AddonSherlock$HoloActionBarSherlockNative> is not accessible from java.lang.Class<com.actionbarsherlock.ActionBarSherlock>
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.ActivityThread.-wrap11(ActivityThread.java)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.os.Looper.loop(Looper.java:148)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.ActivityThread.main(ActivityThread.java:5415)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at java.lang.reflect.Method.invoke(Native Method)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)
07-31 10:41:59.435: E/AndroidRuntime(4239): Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: java.lang.Class<org.holoeverywhere.addon.AddonSherlock$HoloActionBarSherlockNative> is not accessible from java.lang.Class<com.actionbarsherlock.ActionBarSherlock>
07-31 10:41:59.435: E/AndroidRuntime(4239):     at com.actionbarsherlock.ActionBarSherlock.wrap(ActionBarSherlock.java:240)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at org.holoeverywhere.addon.AddonSherlock$AddonSherlockA.getSherlock(AddonSherlock.java:53)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at org.holoeverywhere.addon.AddonSherlock$AddonSherlockA.installDecorView(AddonSherlock.java:60)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.support.v4.app._HoloActivity$1.action(_HoloActivity.java:587)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.support.v4.app._HoloActivity$1.action(_HoloActivity.java:1)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at org.holoeverywhere.addon.IAddonBasicAttacher.performAddonAction(IAddonBasicAttacher.java:167)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at org.holoeverywhere.app.Activity.performAddonAction(Activity.java:497)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.support.v4.app._HoloActivity.requestDecorView(_HoloActivity.java:584)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.support.v4.app._HoloActivity.setContentView(_HoloActivity.java:604)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at com.myapp.messaging.android.holo.messagelist.MainActivity.onCreate(MainActivity.java:120)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.Activity.performCreate(Activity.java:6162)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
07-31 10:41:59.435: E/AndroidRuntime(4239):     ... 9 more
07-31 10:41:59.435: E/AndroidRuntime(4239): Caused by: java.lang.IllegalAccessException: java.lang.Class<org.holoeverywhere.addon.AddonSherlock$HoloActionBarSherlockNative> is not accessible from java.lang.Class<com.actionbarsherlock.ActionBarSherlock>
07-31 10:41:59.435: E/AndroidRuntime(4239):     at java.lang.reflect.Constructor.newInstance(Native Method)
07-31 10:41:59.435: E/AndroidRuntime(4239):     at com.actionbarsherlock.ActionBarSherlock.wrap(ActionBarSherlock.java:232)
07-31 10:41:59.435: E/AndroidRuntime(4239):     ... 21 more

1 个答案:

答案 0 :(得分:7)

我今天遇到了完全相同的问题,幸运的是我能够解决它。 此修复必须在actionbar sherlock库代码中完成。因此,您需要将actionbarsherlock添加为库项目。

在ActionBarSherlock.java中进行以下更改

ctor.setAccessible(true);

在上面的行上面添加返回ctor.newInstance(activity,flag); (公共静态ActionBarSherlock换行中的第230行(Activity activity,int flags){}方法。

同样在LayoutInflater.java中进行以下更改

constructor.setAccessible(true); 

将其添加到最终的View view = constructor.newInstance(args);公共视图中的(第327行)_createView(String name,String prefix,AttributeSet attrs){}

注意:我正在使用ActionBarSherlock 4.3.0