ActionBarSherlock type mAdded cannot be resolved or is not a field Watson.java… here is a solution to the problem.
ActionBarSherlock type mAdded cannot be resolved or is not a field Watson.java
I spent a day looking for a solution to this error
I downloaded ActionBarSherlock and imported the library into Eclipse
I have fixed all the bugs and this is the last one
I checked all layouts with no xml errors, cleaned up the workspace and restarted Eclipse
Here is the error description:
Description Resource Path Location Type mAdded cannot be resolved or
is not a
field Watson.java /abs_library/src/android/support/v4/app line 59 Java
Problem
Code
if (mFragments.mAdded != null) {
for (int i = 0; i < mFragments.mAdded.size(); i++) {
Fragment f = mFragments.mAdded.get(i);
if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible
&& f instanceof OnCreateOptionsMenuListener) {
show = true;
((OnCreateOptionsMenuListener) f).onCreateOptionsMenu(
menu, inflater);
if (newMenus == null) {
newMenus = new ArrayList<Fragment>();
}
newMenus.add(f);
}
}
}
Thanks
Solution
If you update your android-support-v4 .jar, just replace those three lines of code
if (mFragments.mAdded != null) {
for (int i = 0; i < mFragments.mAdded.size(); i++) {
Fragment f = mFragments.mAdded.get(i);
with
List<Fragment> actives = mFragments.getActiveFragments(null);
if (actives != null) {
for (int i = 0; i < actives.size(); i++) {
Fragment f = actives.get(i);
…
Everything will be fine