trello-archive / victor

Use SVGs as resources in Android
Apache License 2.0
1.01k stars 49 forks source link

Usage Of Plugin Inside Android Library Module #13

Closed cavega closed 9 years ago

cavega commented 9 years ago

For an Android project with a main app module and multiple library modules there seems to be issues using Victor at the library module level. In my project, everything works great when Victor is configured in the main app module's build.gradle file. However, modifying the library module's build.gradle so that SVGs files can be placed inside the library's own svg directory seem to produce Gradle errors. I modified my library module's build.gradle as follows:

apply plugin: 'com.android.library'
apply plugin: 'retrolambda'
apply plugin: 'com.trello.victor'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    sourceSets {
        main {
            svg.srcDir 'src/main/svg'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    ...

    victor {
        // Any assets defined in relative terms needs a base DPI specified
        svgDpi = 72

        // Do not generate these densities for SVG assets
        excludeDensities = [ 'ldpi', 'xxxhdpi' ]
    }

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

}

retrolambda {
    jvmArgs '-noverify'
}

I get the following error: _Error:Could not find property 'applicationVariants' on com.android.build.gradle.LibraryExtensionDecorated@66e56cf0.

Question: Does Victor currently provides any support for library modules? Or am I missing something in my build.gradle file? I get the same error regardless if I also define Victor in both the app and library modules' build.gradle files or if I have it only in the library module.

dlew commented 9 years ago

Ah, this is because we built it with apps in mind, not libraries, but this should be supported. I'll look into it soon.

cavega commented 9 years ago

Understandable. This is more of a unique case where the project using internal libraries which happen to have UI logic and hence drawables. It'll be great if it can be supported. Thanks for the feedback.

dlew commented 9 years ago

@cavega I've published Victor 0.1.3 to jcenter; it should show up there soon.