Android: java.land.NoSuchFieldError after update t

2019-01-23 23:32发布

I updated to SDK 23 and updated the gradle.build to API 23, support library to 23.0.0, etc and am now getting the following error when trying to run the app (compiles just fine).

java.lang.NoSuchFieldError: No instance field mFragments of type Landroid/support/v4/app/FragmentManagerImpl; in class Landroid/support/v4/app/Watson; or its superclasses (declaration of 'android.support.v4.app.Watson' appears in /data/app/com.my.app-1/base.apk)
            at android.support.v4.app.Watson.onCreatePanelMenu(Watson.java:50)
            at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:560)
            at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:64)
            at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:164)
            at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:548)
            at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:917)
            at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:258)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

I reverted back to API 22 on everything and still get the error.

6条回答
混吃等死
2楼-- · 2019-01-23 23:59

I did the some thing as you did , but I found gradle can solve dependencies, in External Libraries i cannot find support-v4-23.0.0,support-v7-23.0.0 and other lib which the version is 23.0.0. then I reverted back to compile 'com.android.support:support-v4:22.2.0', the problem solver @mraviator

查看更多
The star\"
3楼-- · 2019-01-24 00:02

Thank you @zmarties for the answer , I want to add the details and links

  1. Remove 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' from gradle
  2. Download actionbarsherlock module from this link!
  3. Verify that you have 'com.android.support:support-v4:20.0.0' or 23
  4. Open the actionbarsherlock module src change FloatMath to Math in AnimatorProxy.java
  5. Open the actionbarsherlock module src create variable fragments in class level scope as FragmentManagerImpl fragments = (FragmentManagerImpl) this.getSupportFragmentManager(); in Watson.java
  6. Replace all mFragments occurrence with fragments variable

Thank you for the above answers .

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-24 00:07

i had the same problem when import project eclipse to Android Studio

This is best solution for me

I found that I could build ActionBarSherlock using SDK 23 if I made the following two sets of changes:

in AnimatorProxy.java, replace FloatMath calls with their corresponding Math calls - i change FloatMath - to Math

in Waston Class i had the error - mFragments.isadded So, i replace the follow code instead of checking

mFragments.isadded != null

to

mFragments.getActiveFragments(mCreatedMenus)

everywher when it required

i had solve these issues.

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-24 00:08

Using google play services version 8.1.0 instead of 8.4.0 solved on my side

查看更多
够拽才男人
6楼-- · 2019-01-24 00:14

Did you change the theme view in the main layout from the design tab? Try changing it again to a Sherlock theme view at the design tab.

查看更多
我只想做你的唯一
7楼-- · 2019-01-24 00:17

I found that I could build ActionBarSherlock using SDK 23 if I made the following two sets of changes:

  • in AnimatorProxy.java, replace FloatMath calls with their corresponding Math calls
  • in Watson.java, replace the use of the mFragments field with a local variable fragments initialized via getActiveFragments(null), and then change the mFragment references to use the local variable
查看更多
登录 后发表回答