NoClassDefFoundError:with PreferenceFragmentCompat

197 views Asked by At

I am doing an application using the PreferenceFragmentCompat when i call the PreferenceFragmentCompat i am getting the error like java.lang.NoClassDefFoundError i am getting the confused what to do i have tried and checked some google suggestion it is not solving the problem please help to solve it my Class which extends PreferenceFragmentCompat is as i am showing the code below

public class AutoAnswerPreferenceActivity extends PreferenceFragmentCompat implements OnSharedPreferenceChangeListener { 
    private AutoAnswerNotifier mNotifier;
    @Override
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preference);
        mNotifier = new AutoAnswerNotifier(getActivity()); 
        mNotifier.updateNotification();
        SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
        sharedPreferences.registerOnSharedPreferenceChangeListener(this);
        /*PreferenceManager preferenceManager = getPreferenceManager();
        preferenceManager.getSharedPreferences()
                .registerOnSharedPreferenceChangeListener(this);*/


        }

    @Override
    public void onDestroy() { 
        getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
        super.onDestroy();
        }
    @Override 
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 
        if (key.equals("enabled")) { 
            mNotifier.updateNotification();
            }  
        }


    @Override
    public void onCreatePreferences(Bundle arg0, String arg1) {
        // TODO Auto-generated method stub

    } 

and my fragment class is as shown below

public class AutoAnswarFragment extends Fragment {


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        // getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container, new AutoAnswerPreferenceActivity()).commit();
        getActivity().getSupportFragmentManager().beginTransaction()
        .replace(R.id.container, new AutoAnswerPreferenceActivity ()).commit();

    }



    }

In Navigation Drawer i am calling the fragment to replace it as shown below

getSupportFragmentManager().beginTransaction()
            .replace(R.id.container, new AutoAnswarFragment(),null).commit(); 

the manifest file is as shown below

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".NavigationDrawerMainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name="com.koteswara.wise.autoanswer.AutoAnswerReceiver"
            android:enabled="true" >
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.koteswara.wise.autoanswer.AutoAnswerBootReceiver"
            android:enabled="true" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <service android:name="com.koteswara.wise.autoanswer.AutoAnswerIntentService" />

         <activity android:name="com.koteswara.wise.settings.GetCallerInfoActivity" 
                android:theme="@android:style/Theme.Dialog"
       ></activity>
    </application> 

please help to solve this i will be great full to you people. I am getting this error from the last one week

0

There are 0 answers