Created
October 10, 2018 11:17
-
-
Save haxpor/7da795ef505ff65773dbd1af8a11e2d1 to your computer and use it in GitHub Desktop.
Gradle build file that works to build Android via NDK 15c with SDL2 2.0.8 that produces all libraries in architecture we need (note: we need to specify abiFilters for both debug and release target then filter what we need in android domain)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY'); | |
def buildAsApplication = !buildAsLibrary | |
if (buildAsApplication) { | |
apply plugin: 'com.android.application' | |
} | |
else { | |
apply plugin: 'com.android.library' | |
} | |
android { | |
compileSdkVersion 26 | |
buildToolsVersion "26.0.2" | |
defaultConfig { | |
if (buildAsApplication) { | |
applicationId "org.libsdl.app" | |
} | |
minSdkVersion 14 | |
targetSdkVersion 26 | |
versionCode 1 | |
versionName "1.0" | |
externalNativeBuild { | |
ndkBuild { | |
arguments "APP_PLATFORM=android-14" | |
} | |
} | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
ndk { | |
abiFilters 'armeabi-v7a', 'arm64-v8a' | |
} | |
} | |
packagingOptions { | |
doNotStrip '*/mips/*.so' | |
doNotStrip '*/mips64/*.so' | |
} | |
buildTypes { | |
debug { | |
ndk { | |
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' | |
} | |
} | |
release { | |
ndk { | |
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' | |
} | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) { | |
sourceSets.main { | |
jniLibs.srcDir 'libs' | |
} | |
externalNativeBuild { | |
ndkBuild { | |
path 'jni/Android.mk' | |
} | |
} | |
} | |
lintOptions { | |
abortOnError false | |
} | |
if (buildAsLibrary) { | |
libraryVariants.all { variant -> | |
variant.outputs.each { output -> | |
def outputFile = output.outputFile | |
if (outputFile != null && outputFile.name.endsWith(".aar")) { | |
def fileName = "org.libsdl.app.aar"; | |
output.outputFile = new File(outputFile.parent, fileName); | |
} | |
} | |
} | |
} | |
} | |
dependencies { | |
compile fileTree(include: ['*.jar'], dir: 'libs') | |
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | |
exclude group: 'com.android.support', module: 'support-annotations' | |
}) | |
testCompile 'junit:junit:4.12' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment