import groovy.xml.XmlUtil apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion '26.0.2' buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions { abortOnError false } compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } } gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar') } } preBuild { doLast { def imlFile = file(project.name + ".iml") 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" new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) } catch (FileNotFoundException ex) { ex.printStackTrace() } } } dependencies { provided fileTree(include: ['*.jar'], dir: 'libs') compile group: 'commons-io', name: 'commons-io', version: '2.6' }