Thursday, May 17, 2018

Add Stub module on Android studio

1. Create java library module, not Android library.
    apply plugin: 'java'
    Write stub code in this module

2. Add reference Stub in build.gradle in app module

android {

allprojects {
                   gradle.projectsEvaluated {
                     tasks.withType(JavaCompile) {
                       doFirst {
                         options.fork = true
                         options.compilerArgs.add("-Xbootclasspath/p:$project.rootDir/stub/build/libs/stub.jar")
                       }
                     }
                   }
                  }
}
dependencies {
compileOnly project(':stub')
}

No comments:

Post a Comment