Skip to content

Instantly share code, notes, and snippets.

@trongvu
Created January 2, 2019 02:09
Show Gist options
  • Save trongvu/0d1c9e4b7bad3c78e030773e3fcbdc50 to your computer and use it in GitHub Desktop.
Save trongvu/0d1c9e4b7bad3c78e030773e3fcbdc50 to your computer and use it in GitHub Desktop.
Inlcude Custom Android framework jar to Android Studio
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add('-Xbootclasspath/p:mobile/framework.jar')
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
preBuild {
doLast {
def imlFile = file(project.name + ".iml")
println 'Change ' + project.name + '.iml order'
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
println 'what' + sdkString
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (FileNotFoundException e) {
// nop, iml not found
println "no iml found"
}
}
}
...
dependencies {
compileOnly files('framework.jar')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment