In project build.gradle, do:
- Add
maven { url 'https://jitpack.io'
in the repositories block
repositories {
maven {
url url 'https://jitpack.io'
}
google()
jcenter()
...
}
- Add
classpath "com.github.yeuristic:dynamic-feature-resource-migration:master-SNAPSHOT"
in the dependencies block
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.yeuristic:dynamic-feature-resource-migration:master-SNAPSHOT"
...
}
- Add this to the subproject block, if you don't have subproject block you can create it
subprojects {
pluginManager.withPlugin("com.android.dynamic-feature") {
apply plugin: 'com.yeuristic.dynamic-feature-resource-migration'
migrationDM {
baseRFullName = "<your application package>.R"
}
}
}
change <your application package>
with your application package, if you don't know your application package you can copy it from BuildConfig.APPLICATION_ID
- Select dynamic feature module target, let's say we are targeting module named dynamicfeature.
- Run
./gradlew --build-cache dynamicfeature:migrateResources
. - If your dynamic module directory is not direct child of the project directory, you should specify
srcPath
. For example if your dynamic module directory path = ./dynamic/dynamicfeature --> run./gradlew --build-cache dynamic:dynamicfeature:migrateResources -PsrcPath=./dynamic/dynamicfeature/src
- After it is finished, there will be some changes in your .kt, .java or .xml files.
- If you want to run it for another module just change dynamicfeature with the new target module. Eg:
./gradlew --build-cache otherdynamicfeature:migrateDynamicModule
.
Checkout this example project.