[Android] Refactor gradle native build

Geoffrey Métais git at videolan.org
Fri Feb 6 15:37:49 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb  6 15:12:19 2015 +0100| [277dee99506e4a67ae870dc4179b5d576ccce664] | committer: Geoffrey Métais

Refactor gradle native build

- Release buildType doesn't build jni anymore
- Debug variant for x86

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=277dee99506e4a67ae870dc4179b5d576ccce664
---

 libvlc/build.gradle      |   17 +++++------------
 vlc-android/build.gradle |   14 +++++++++++---
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/libvlc/build.gradle b/libvlc/build.gradle
index a06ff4f..f45f1f3 100644
--- a/libvlc/build.gradle
+++ b/libvlc/build.gradle
@@ -1,6 +1,7 @@
 apply plugin: 'com.android.library'
 
-task buildDebug(type:Exec) {
+
+task buildDebugARM(type:Exec) {
     /*
     Properties set for Android Studio own shell.
     when you run gradlew from cli, OS shell env variables will be used
@@ -16,17 +17,17 @@ task buildDebug(type:Exec) {
     }
     workingDir '..'
     commandLine './compile-libvlc.sh'
+    args('-a', "armeabi-v7a")
 }
 
-task buildRelease(type:Exec) {
+task buildDebugx86(type:Exec) {
     if (System.getenv('ANDROID_SDK') == null || System.getenv('ANDROID_NDK') == null) {
         environment 'ANDROID_NDK', ndk
         environment 'ANDROID_SDK', sdk
     }
-
     workingDir '..'
     commandLine './compile-libvlc.sh'
-    args('--release')
+    args('-a', "x86")
 }
 
 android {
@@ -50,14 +51,6 @@ android {
     defaultConfig {
         minSdkVersion 7
         targetSdkVersion 21
-
-        tasks.whenTaskAdded { task ->
-            if (task.name == 'bundleDebug') {
-                task.dependsOn buildDebug
-            } else if (task.name == 'bundleRelease') {
-                task.dependsOn buildRelease
-            }
-        }
     }
 
     buildTypes {
diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index ca6b3ad..a8ae8ab 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -13,6 +13,16 @@ android {
         applicationId "org.videolan.vlc"
         minSdkVersion 7
         targetSdkVersion 21
+
+        //Set the build ABI according to build types
+        tasks.whenTaskAdded { task ->
+            if (task.name.startsWith('assemble')) {
+                if (task.name.endsWith('Debug'))
+                    task.dependsOn(":libvlc:buildDebugARM")
+                else if (task.name.endsWith('Debugx86'))
+                    task.dependsOn(":libvlc:buildDebugx86")
+            }
+        }
     }
 
      signingConfigs {
@@ -39,9 +49,7 @@ android {
             shrinkResources true
             proguardFile 'proguard.cfg'
         }
-        debug {
-            debuggable true
-        }
+        debugx86.initWith(debug)
     }
     productFlavors {
         vanilla {



More information about the Android mailing list