Skip to content

Instantly share code, notes, and snippets.

View ph0b's full-sized avatar

Xavier Hallade ph0b

View GitHub Profile
@ph0b
ph0b / build.gradle
Created April 11, 2016 14:57
including another module libXXX which is a com.android.model.native
apply plugin: 'com.android.model.application'
model {
//...
android.sources {
main {
jni {
dependencies {
project ":libXXX" linkage "static"
}
@ph0b
ph0b / app_build.gradle
Last active November 20, 2019 09:21
config example on Multiple APK support and mixing gradle-stable and gradle-experimental plugin, for NDK-enabled Android projects. To support AS 2.0 debug, just add lib/build/intermediates/binaries/release/obj/[abi] to Symbol directories
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.example.yourapp"
minSdkVersion 16
targetSdkVersion 23
@ph0b
ph0b / build.gradle
Last active May 15, 2017 08:04
gradle configuration for a module depending on a prebuilt native library - using gradle-experimental:0.6.0+ plugin.
apply plugin: 'com.android.model.library'
model {
repositories {
libs(PrebuiltLibraries) {
mydependency {
headers.srcDir "src/main/jni/prebuilts/include"
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("src/main/jni/prebuilts/${targetPlatform.getName()}/libmydependency.so")
@ph0b
ph0b / custom_rules.xml
Created July 15, 2015 13:17
ant rule to prefix APK version code depending on the native code of the APK being generated. useful for Visual Studio 2015 Android projects.
<?xml version="1.0" encoding="utf-8"?>
<project name="custom_rules">
<available file="libs/x86" property="x86Dir.exists"/>
<available file="libs/armeabi-v7a" property="armDir.exists"/>
<target name="-pre-build-x86" if="x86Dir.exists" unless="armDir.exists">
<echo>prefixing version code with 5 (for x86 ABI).</echo>
<replaceregexp file="AndroidManifest.xml" match="android:versionCode.*([0-9]+).*"
replace='android:versionCode="5\1"'/>
@ph0b
ph0b / build.gradle
Last active February 22, 2016 07:28
build gradle with ndk build tasks that are using an alternative configuration or Application.mk for debug builds, using the new model.
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = rootProject.ext.compileSdkVersion
buildToolsVersion = rootProject.ext.buildToolsVersion
defaultConfig.with {
@ph0b
ph0b / build.gradle
Last active February 12, 2023 07:45
sample build.gradle for generating split APKs per ABI
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig{
minSdkVersion 14
targetSdkVersion 21
versionCode 101
@ph0b
ph0b / build.gradle
Last active November 30, 2016 08:55
gradle config example for building ndk sources using standard Makefiles and libs folder, and having flavors for ABIs
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig{
minSdkVersion 14