consp1racy / android-support-preference

Android Preferences according to Material design specs
Apache License 2.0
331 stars 49 forks source link

Wildcard support libs dependency #48

Closed Pahanuch closed 7 years ago

Pahanuch commented 8 years ago

I just added library to project and app crash when starting. After I deleted dependence - the app works again!

dependencies {
    compile 'net.xpece.android:support-preference:1.0.3'
}
09-17 18:38:17.207 19437-19437/proviser.legalapps.com.proviser E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                 Process: proviser.legalapps.com.proviser, PID: 19437
                                                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{proviser.legalapps.com.proviser/proviser.legalapps.com.proviser.ClassicMenuActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class android.support.design.widget.FloatingActionButton
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                                     at android.os.Looper.loop(Looper.java:193)
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5333)
                                                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                     at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
                                                                                     at dalvik.system.NativeStart.main(Native Method)
                                                                                  Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class android.support.design.widget.FloatingActionButton
                                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                                                                                     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
                                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                                                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                                     at proviser.legalapps.com.proviser.ClassicMenuActivity.onCreate(ClassicMenuActivity.java:148)
                                                                                     at android.app.Activity.performCreate(Activity.java:5343)
                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429) 
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                     at android.os.Looper.loop(Looper.java:193) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5333) 
                                                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                     at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
                                                                                     at dalvik.system.NativeStart.main(Native Method) 
                                                                                  Caused by: java.lang.reflect.InvocationTargetException
                                                                                     at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                                     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
                                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                                     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
                                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                     at proviser.legalapps.com.proviser.ClassicMenuActivity.onCreate(ClassicMenuActivity.java:148) 
                                                                                     at android.app.Activity.performCreate(Activity.java:5343) 
                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331) 
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429) 
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                     at android.os.Looper.loop(Looper.java:193) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5333) 
                                                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                     at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
                                                                                     at dalvik.system.NativeStart.main(Native Method) 
                                                                                  Caused by: java.lang.NoSuchMethodError: android.support.v7.widget.AppCompatImageHelper.<init>
                                                                                     at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:170)
                                                                                     at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:147)
                                                                                     at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                                     at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
                                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
                                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                                     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
                                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                     at proviser.legalapps.com.proviser.ClassicMenuActivity.onCreate(ClassicMenuActivity.java:148) 
                                                                                     at android.app.Activity.performCreate(Activity.java:5343) 
                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331) 
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429) 
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                     at android.os.Looper.loop(Looper.java:193) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5333) 
                                                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                     at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
                                                                                     at dalvik.system.NativeStart.main(Native Method) 
consp1racy commented 8 years ago

In any case post your module build.gradle file.


Specifying the aar artifact explicitly will prevent pulling in transitive dependencies. Then you'll need to manually add the denpendencies.

ext.supportLibVersion = "24.1.1"
compile "com.android.support:preference-v7:$supportLibVersion"
compile 'net.xpece.android:support-preference:1.0.3@aar'
compile 'net.xpece.android:support-spinner:1.0.2@aar'

If that didn't fix it, you may have gone over 65K method limit. Google multidex.

Pahanuch commented 8 years ago

Thanks, but now I get errors when build project! compile 'net.xpece.android:support-spinner:1.0.2@aar' compile ok. Problem with compile 'net.xpece.android:support-preference:1.0.3@aar'

error

consp1racy commented 8 years ago

I can provide more info once you do what I asked.

Pahanuch commented 8 years ago

My module build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "proviser.legalapps.com.proviser"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }

    /* dexOptions {
        incremental true
        javaMaxHeapSize "2048M"
    }*/

    android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/LGPL2.1'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/notice.txt'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'

    compile files('libs/jxl.jar')
    compile files('libs/android-viewbadger.jar')

    compile files('libs/httpclient-4.0.jar')
    compile files('libs/httpcore-4.0.1.jar')
    compile files('libs/jsoup-1.8.3.jar')

    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.prolificinteractive:material-calendarview:1.4.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'cn.pedant.sweetalert:library:1.3'
    compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
    compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
    compile 'com.afollestad.material-dialogs:commons:0.9.0.1'
    compile 'com.afollestad.material-dialogs:core:0.9.0.1'
    compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
    compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services-maps:9.2.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'dev.dworks.libs:astickyheader:0.1.0'
    compile 'se.emilsjolander:stickylistheaders:2.7.0'
    compile 'net.xpece.android:support-preference:1.0.3@aar'
}
consp1racy commented 8 years ago

Thank you, I updated my original comment, which should now fix the issue.

Another solution would be to update to support libs 24.2.+.

Pahanuch commented 8 years ago

Thanks, it resolved a problem. But this solution works only if I add to this support-spinner

ext.supportLibVersion = "24.1.1"
compile "com.android.support:preference-v7:$supportLibVersion"
compile 'net.xpece.android:support-preference:1.0.3@aar'
compile 'net.xpece.android:support-spinner:1.0.2@aar'

This I get when I don't add compile 'net.xpece.android:support-spinner:1.0.2@aar'

error

consp1racy commented 8 years ago

Ah, you're right, good catch. I will try and make this* easier in future releases.

*using the library with older support libs