Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.vokal:android-res-gen:'
}
dependencies {
implementation("com.github.vokal:android-res-gen:")
}
<dependency>
<groupId>com.github.vokal</groupId>
<artifactId>android-res-gen</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.vokal" % "android-res-gen" % ""
:dependencies [[com.github.vokal/android-res-gen ""]]
Automatic resource exporter plugin for android projects: generating density specific drawables from PDF files.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:${toolsVersion}'
classpath 'io.vokal.gradle:resgen:1.0.1'
}
}
buildscript {
repositories {
…
}
dependencies {
classpath 'com.android.tools.build:gradle:${toolsVersion}'
classpath files('libs/resgen-1.0.1.jar')
classpath 'org.apache.pdfbox:pdfbox:2.0.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.vokal.resgen'
android {
…
// if PDF files are placed in a folder named 'res-gen' they will be recognized automatically
// or you can configure the location of your PDF files with the following
sourceSets {
main {
pdf.srcDir 'src/main/pdf'
}
}
}
resgen {
densities "mdpi", "hdpi", "xhdpi", "xxhdpi"
jpeg "bg_*", "exact_filename" // may contain wildcards (* or ?) or regex
jpegQuality 80 // default is 85 if only jpeg patterns specified
mipmap "ic_launcher", "*_image" // names of assets you would like in mipmap folders (wildcard or regex accepted)
mipmapDensities "hdpi", "xhdpi", "xxhdpi", "xxxhdpi" // densities for mipmaps, defaults to densities
}
Densities are from the set: ["ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"]
(xxxhdpi is only applicable for mipmapDensities)
Place PDF assets file in /main/src/res-gen
folder (or whatever your sourceDir is set to.)
If you have alternative resources for different configurations (language, orientation, smallest width) you can nest the structure in res-gen
folder:
res-gen/
en/
port/
background.pdf
land/
background.pdf
es/
port/
background.pdf
land/
background.pdf
You must follow the Qualifier name rules and order the nesting as Android expects. (currently only accepts qualifiers listed before density (dpi) in the table)
Drawables are generated from PDF files as part of the build process or can be generated manually with gradle task generate{variantName}ResRasterizePdf
.
eg. generateDebugResRasterizePdf
, generateStageDebugResRasterizePdf
Drawables will be re-generated automatically when PDF file is updated.