playback/player/android: Switch to native gradle ndk-build support

Based on a patch by Olivier Crete for another project
  be9470a7e1
This commit is contained in:
Sebastian Dröge 2016-10-03 13:14:37 +03:00
parent a5cdde9119
commit 8b0ea8257f
2 changed files with 24 additions and 45 deletions

View file

@ -1,44 +1,34 @@
apply plugin: 'com.android.application'
def getNdkCommandLine(ndkRoot, target) {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
gstRoot = project.gstAndroidRoot
else
throw new GradleException('"gstAndroidRoot" must be defined in your gradle properties to the top level directory of the unpacked universal GStreamer Android binaries')
if (ndkRoot == null)
throw new GradleException('NDK not configured')
return ["$ndkRoot/ndk-build",
'NDK_PROJECT_PATH=build',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk',
'GSTREAMER_JAVA_SRC_DIR=src/main/java',
"GSTREAMER_ROOT_ANDROID=$gstRoot",
target]
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
sourceSets {
main {
// Avoid using the built in JNI generation plugin
jni.srcDirs = []
jniLibs.srcDirs = ['build/libs']
}
}
defaultConfig {
applicationId "org.freedesktop.gstreamer.play"
minSdkVersion 15
targetSdkVersion 15
versionCode 1
versionName "1.0"
externalNativeBuild {
ndkBuild {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
gstRoot = project.gstAndroidRoot
else
throw new GradleException('"gstAndroidRoot" must be defined in your gradle.properties to the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=src/main/jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src/main/java", "GSTREAMER_ROOT_ANDROID=$gstRoot"
targets "gstplayer", "gstreamer_android"
// All archs except MIPS and MIPS64 are supported
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
}
buildTypes {
@ -48,21 +38,10 @@ android {
}
}
// Before compiling our app, prepare NDK code
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
// Need to call clean on NDK ourselves too
clean.dependsOn 'ndkClean'
// Build native code using mk files like on Eclipse
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
commandLine getNdkCommandLine(android.ndkDirectory, 'all')
}
task ndkClean(type: Exec, description: 'Clean JNI code built via NDK') {
commandLine getNdkCommandLine(android.ndkDirectory, 'clean')
}
}

View file

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files