I migrated a project of 2 years old to Android Studio (and the new lib), I have a lot of problems when I call a PreferenceScreen.
java.lang.NoSuchFieldError: No static field list_container of type I in class Landroid/support/v7/preference/R$id; or its superclasses (declaration of 'android.support.v7.preference.R$id' appears in /data/app/com.sh.inv-1/base.apk)
at android.support.v7.preference.PreferenceFragmentCompat.onCreateView(PreferenceFragmentCompat.java:260)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1988)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1268)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:754)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1653)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:364)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:602)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)
My build.gradle is :
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.sh.inv"
targetSdkVersion 23
versionCode 66
versionName "2.5.0"
}
buildTypes {
debug {
}
release {
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
productFlavors {
dev {
minSdkVersion 21
}
prod {
minSdkVersion 14
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
repositories {
maven { url "http://jzaccone.github.io/SlidingMenu-aar" }
}
dependencies {
compile files('libs/ormlite-android-4.48.jar')
compile files('libs/ormlite-core-4.48.jar')
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:preference-v7:23.2.1'
compile 'com.android.support:preference-v14:23.2.1'
compile "com.android.support:appcompat-v7:23.2.1"
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'
compile 'org.apache.commons:commons-io:+'
compile 'com.cocosw:undobar:1.8.1@aar'
compile project(':afilechooser')
compile project(':simplecropimage')
}
My Fragment is :
public class Settings extends android.support.v7.preference.PreferenceFragmentCompat implements
OnSharedPreferenceChangeListener {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.settings2);
My AppBaseTheme is :
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
I really don't understand how to resolve it. I tried to:
< uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" xmlns:tools="http://schemas.android.com/tools" tools:overrideLibrary="android.support.v14.preference"/>
This problem will happen whenever in one application has two files with the same name in two different modules.
For example in a STACK application. 2 modules are there 1. stac1 2. stac2 in stac1->res->layout has miniactivity.xml in stac2->res->layout has miniactivity.xml
then you will get this problem. If you delete any one xml file it will works fine.
I finally found the problem. I had a layout which was called preference_list_fragment.xml. It works after deleting the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With