[Libreoffice-commits] core.git: android/.gitignore android/README android/source

Christian Lohmaier lohmaier+LibreOffice at googlemail.com
Tue Oct 13 18:21:03 PDT 2015


 android/.gitignore                 |    2 ++
 android/README                     |   23 ++++++++++++++++-------
 android/source/AndroidManifest.xml |    3 ++-
 android/source/ReleaseManifest.xml |    7 +++++++
 android/source/build.gradle        |   27 ++++++++++++++++++++-------
 5 files changed, 47 insertions(+), 15 deletions(-)

New commits:
commit 78cf4ca4405d33d3f658da0d7f209afc8e6ee4a7
Author: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Date:   Wed Oct 14 02:32:57 2015 +0200

    make ndk-gdb work again
    
    it hardcodes so much :-(
    
    Change-Id: Id86c2bcbf5936f3ab292e87210b967e2331c9435

diff --git a/android/.gitignore b/android/.gitignore
index 0487562..c937757 100644
--- a/android/.gitignore
+++ b/android/.gitignore
@@ -5,9 +5,11 @@
 /source/assets_strippedUI/
 /source/build/
 /source/captures/
+/source/jni/Application.mk
 /source/jniLibs/
 /source/jniLibs_debug/
 /source/liboSettings.gradle
+/source/libs/*/gdb.setup
 /source/local.properties
 /source/native-code.cxx
 /source/obj/
diff --git a/android/README b/android/README
index 513444c..8f40d5a 100644
--- a/android/README
+++ b/android/README
@@ -198,16 +198,25 @@ Building with all symbols is also possible but the linking is currently
 slow (around 10 to 15 minutes) and you need lots of memory (around 16GB + some
 swap).
 
-You also want to avoid --with-android-package-name (or when you use
-that, you must set it to "org.libreoffice"), otherwise ndk-gdb will complain:
-
-	ERROR: Could not extract package's data directory. Are you sure that
-	       your installed application is debuggable?
-
 When you have all this, install the .apk to the device, and:
 
         cd android/source
-        <android-ndk-r10d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb --start
+        <ndk-bundle>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb [--start]
+
+In case you used --with-android-package-name, add --package=your.package.name
+to the invocation
+
+If you get the error
+
+        ERROR: Could not find gdb.setup under ./libs/
+
+(and an empty "Compatible device ABI:" when run with --verbose), you need to fix
+the quoting in the ndk-gdb script:
+
+@@ -574 +574 @@
+-adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c "ls lib/*.bc"
++adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c \"ls lib/*.bc\"
+
 
 Pretty printers aren't loaded automatically due to the single shared
 object, but you can still load them manually. E.g. to have a pretty-printer for
diff --git a/android/source/AndroidManifest.xml b/android/source/AndroidManifest.xml
index f15e66f..7721c69 100644
--- a/android/source/AndroidManifest.xml
+++ b/android/source/AndroidManifest.xml
@@ -13,6 +13,7 @@
         android:allowBackup="true"
         android:icon="@drawable/main"
         android:label="@string/app_name"
+        android:debuggable="true"
         android:hardwareAccelerated="true"
         android:largeHeap="false">
 
@@ -94,7 +95,7 @@
         </activity>
 
         <!-- Document Browser Activity -->
-        <activity android:name=".ui.LibreOfficeUIActivity"
+        <activity android:name="org.libreoffice.ui.LibreOfficeUIActivity"
                   android:label="@string/app_name"
                   android:theme="@style/BrowserTheme">
             <intent-filter>
diff --git a/android/source/ReleaseManifest.xml b/android/source/ReleaseManifest.xml
new file mode 100644
index 0000000..e412fe9
--- /dev/null
+++ b/android/source/ReleaseManifest.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools">
+    <application android:debuggable="false" tools:replace="android:debuggable"/>
+</manifest>
+<!-- vim: shiftwidth=4 softtabstop=4 expandtab:
+-->
diff --git a/android/source/build.gradle b/android/source/build.gradle
index 3f476c2..80772b2 100644
--- a/android/source/build.gradle
+++ b/android/source/build.gradle
@@ -24,7 +24,6 @@ dependencies {
     ])
     compile files("${liboInstdir}/${liboShareJavaFolder}/unoil.jar")
     compile files("${liboWorkdir}/UnpackedTarball/owncloud_android_lib/bin/owncloud-android-library.jar")
-    compile 'com.android.support:support-v4:23.0.1'
     compile 'com.android.support:appcompat-v7:23.0.1'
 }
 
@@ -39,18 +38,24 @@ android {
     // ToDo move to conventional layout, so stuff can be stripped down.
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
+        // override the debuggable flag that needs to be in AndroidManifest.xml
+        // since ndk-gdb awks for the literal string in there :-/
+        release.manifest.srcFile 'ReleaseManifest.xml'
         main.assets.srcDirs = ['assets']
         main.res.srcDirs = ['res']
         main.java.srcDirs = ['../Bootstrap/src', 'src/java']
         main.jniLibs.srcDirs = ['jniLibs']
         main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
-        // gdbserver stuff from separate dir
+        // gdbserver for debugvariant
         debug.jniLibs.srcDirs "jniLibs_debug"
         // the configuration data that might be stripped or not
         fullUI.assets.srcDirs 'assets_fullUI'
         strippedUI.assets.srcDirs 'assets_strippedUI'
     }
-    // defaults for Manifest
+    lintOptions {
+        // ndk-gdb looks for the literal value in the pre-processed manifest :-(
+        disable 'HardcodedDebugMode'
+    }
     defaultConfig {
         minSdkVersion 14
         // openssl on x86 makes the native-code.so contain text-relocations,
@@ -197,16 +202,24 @@ task createStrippedConfigRegistry(type: Exec) {
     }
 }
 
+// ndk-gdb requires the gdb.setup to be in libs/<arch>/ folder - it's hardcoded in the script
+// it should in theory also be able to copy the gdbserver binary onto the device, but the matching
+// against prebuilt archs is too rudimentary and doesn't map armeabi-v7 to arm for example
 task copyNdkDebugServer(type: Copy) {
-    description "copies gdbserver into and creates gdb.setup in the debug-type only native directory"
+    description "copies gdbserver into and creates gdb.setup and Application.mk for use with ndk-gdb"
     inputs.file "liboSettings.gradle"
-    def gdbsetup = file("jniLibs_debug/${liboAndroidAppAbi}/gdb.setup")
-    outputs.file gdbsetup
+    def gdbsetup = file("libs/${liboAndroidAppAbi}/gdb.setup") // only needed on buildhost
+    // hardcoded path from ndk-gdb - reads the host architecture from that file
+    def applicationmk = file("jni/Application.mk")
+    outputs.files gdbsetup, applicationmk
     outputs.dir 'jniLibs_debug' // own the directory, so it is removed on this task's clean
+    outputs.dir 'libs' // own the directory, so it is removed on this task's clean
     into "jniLibs_debug/${liboAndroidAppAbi}"
     from "${liboNdkGdbserver}"
     doLast {
-        gdbsetup.text = "set solib-search-path ./obj/local/${liboAndroidAppAbi}"
+        file("libs/${liboAndroidAppAbi}").mkdirs()
+        gdbsetup.text = "set solib-search-path ./obj/local/${liboAndroidAppAbi}\n"
+        applicationmk.text = "APP_ABI := ${liboAndroidAppAbi}\n"
     }
 }
 


More information about the Libreoffice-commits mailing list