import com.android.builder.core.BuilderConstants apply plugin: 'com.android.library' android { compileSdkVersion androidCompileSdkVersion.toInteger() } task makeStubJar(type: Jar){ dependsOn assemble baseName 'framework-stub' from("${projectDir}/build/intermediates/javac/release/classes/") into('') destinationDir file("${projectDir}/libs") exclude('BuildConfig.class', 'R.class') exclude{ it.name.startsWith('R$')} } afterEvaluate { tasks.withType(JavaCompile) { it.finalizedBy(makeStubJar) } }