Lucas Senechal February 2016

java.lang.NoSuchFieldError: android.support.v4.app.Watson.mFragments

I'm trying to implement ActionBarSherlock swipe menu as I like how this animation slides over the slide menu. Unfortunately I keep getting this error and haven't been able to solve it.

This guy is getting the same error but none of the answers on this solves my problem. Android: java.land.NoSuchFieldError after update to SDK 23

Here is my Gradle file.

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.myegotest.ego_17012016"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //compile 'com.android.support:appcompat-v7:23.1.1'
    //compile 'com.android.support:design:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.facebook.android:facebook-android-sdk:4.9.0'
    compile('com.twitter.sdk.android:twitter:1.12.0@aar') {
        transitive = true;
    }
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    //compile 'com.android.support:multidex:1.0.1'
    compile "com.android.support:support-v4:23.1.1"

    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
        

Answers


Lucas Senechal February 2016

I was able to solve the problem by removing the facebook sdk from my gradle file. Since i need the facebook sdk, i was able to get around this by making MainActivity just extend FragmentActivity instead of SlidingFragmentActivty. I made this inner class inside of MainActivty to extend SlidingActivity, that way i can still use the methods i need.

private class SlidingMenuClass extends SlidingActivity {
        private SlidingMenu sm;

        public SlidingMenuClass(Context ctx){
            sm = new SlidingMenu(ctx);
        }

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setBehindContentView(R.layout.menu_frame);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);


            sm = getSlidingMenu();
            sm.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
            sm.setShadowWidthRes(R.dimen.shadow_width);
            //sm.setShadowDrawable(R.drawable.shadow);
            sm.setFadeDegree(1f);
            sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
            sm.setBehindOffsetRes(R.dimen.behindoffsetRes);
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
                case android.R.id.home:
                    toggle();
                    return true;
            }
            return super.onOptionsItemSelected(item);
        }

    }

Post Status

Asked in February 2016
Viewed 1,035 times
Voted 4
Answered 1 times

Search




Leave an answer