Skip to content

Instantly share code, notes, and snippets.

@LanderlYoung
Created September 27, 2016 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LanderlYoung/0a2f0713a6b5b1390dbe8a163c1ccbe9 to your computer and use it in GitHub Desktop.
Save LanderlYoung/0a2f0713a6b5b1390dbe8a163c1ccbe9 to your computer and use it in GitHub Desktop.
instant-run gradle config
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
final String INSTANT_RUN_CHANNEL = 'INSTRUN_T'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.young.jnirawbytetest"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -fno-exceptions -fvisibility=hidden"
abiFilters 'armeabi', 'armeabi-v7a'
}
}
ndk {
abiFilters 'armeabi', 'armeabi-v7a'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
productFlavors {
//instant-run flavor
"$INSTANT_RUN_CHANNEL" {
minSdkVersion 21
targetSdkVersion 22
multiDexEnabled false
}
}
//set its value according to CI env
def isCiEnv = false
// filter variants.
variantFilter { variant ->
//ignore instant-run variant on CI platform
def ignore = isCiEnv &&
variant.flavors*.name.contains(INSTANT_RUN_CHANNEL)
variant.setIgnore(ignore)
}
applicationVariants.all { variant ->
//Removing multi process settings in manifest, to enable instant-run.
if (variant.name.startsWith(INSTANT_RUN_CHANNEL)) {
variant.outputs.each { output ->
output.processManifest.doLast {
[output.processManifest.instantRunManifestOutputFile,
output.processManifest.manifestOutputFile,
output.processManifest.aaptFriendlyManifestOutputFile
].grep { it?.exists() }.each { manifestFile ->
def oldFileContents = manifestFile.getText('UTF-8')
def newFileContents = oldFileContents.replaceAll('android:process=\".*\"', '')
manifestFile.write(newFileContents, 'UTF-8')
println "remove all android:process attr for ${manifestFile.absolutePath}"
}
}
}
}
}
}
dependencies {
provided 'io.github.landerlyoung:jenny-annotation:0.1.0'
apt 'io.github.landerlyoung:jenny-compiler:0.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.1.1'
testCompile 'junit:junit:4.12'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment