2016-03-09 49 views
1

我開發Android應用程序與以下應用程序建立gradle這個配置:的Android CheckBoxPreference minmum SDK版本

 
apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.test.app" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'io.reactivex:rxandroid:1.1.0' 
    compile 'io.reactivex:rxjava:1.1.0' 
    compile 'com.android.support:appcompat-v7:23.2.0' 
    compile 'com.android.support:support-v4:23.2.0' 
    compile 'com.google.code.gson:gson:2.6.2' 
    compile 'org.apache.commons:commons-lang3:3.4' 
    compile 'com.android.support:design:23.0.0' 
} 

和簡單PreferenceFragment使用XML配置:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> 
<CheckBoxPreference android:title="Application Updates" 
    android:defaultValue="false" 
    android:summary="Simple check box preference." 
    android:key="applicationUpdates" /> 

當我的應用程序上運行api level 23的設備一切正常,但是當我用api 15在模擬器上運行相同的代碼時,出現錯誤:

 
03-09 19:38:01.205 1541-1541/com.test.app E/AndroidRuntime: android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.CheckBox 
... 
some code 
... 
03-09 19:38:01.205 1541-1541/com.test.app E/AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException 
... 
some code 
... 
03-09 19:38:01.205 1541-1541/com.test.app E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_btn_check_mat 

我認爲材料設計庫有些問題,但我不確定,我不知道如何解決這個問題。我想用sdk 15在設備上運行應用程序,但我不能。我如何解決這個問題?

PS。當我從xml配置中刪除CheckBoxPreference時,我的應用程序工作在api 15和api 23.

回答

1

我找到了解決方案。此問題已通過添加:

 
aaptOptions { 
     additionalParameters "--no-version-vectors" 
    } 

到應用程序構建gradle。