Skip to content

Commit

Permalink
android: experimental patches for LLDB debugging on Android Studio 2.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiao committed Aug 31, 2016
1 parent db9a381 commit 49d4065
Show file tree
Hide file tree
Showing 9 changed files with 813 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ cd ..
# targetSdkVersion = 23 // depending on your sdk version
# }
#
# If you want to enable debugging ijkplayer(native modules) on Android Studio 2.2+: (experimental)
# cd android
# sh patch-debugging-with-lldb.sh armv7a
# Install Android Studio 2.2(+)
# Preference -> Android SDK -> SDK Tools
# Select (LLDB, NDK, Android SDK Build-tools,Cmake) and install
# Open an existing Android Studio project
# Select android/ijkplayer
# Sync Project with Gradle Files
# Run -> Edit Configurations -> Debugger -> Symbol Directories
# Add "ijkplayer-armv7a/.externalNativeBuild/ndkBuild/release/obj/local/armeabi-v7a" to Symbol Directories
# Run -> Debug 'ijkplayer-example'
# if you want to reverse patches:
# sh patch-debugging-with-lldb.sh reverse armv7a
#
# Eclipse: (obselete)
# File -> New -> Project -> Android Project from Existing Code
# Select android/ and import all project
Expand Down
70 changes: 70 additions & 0 deletions android/patch-debugging-with-lldb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Chen Hui <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

patch_enable () {
PARAM_TARGET=$1
case "$PARAM_TARGET" in
armv5|armv7a|arm64|x86|x86_64)
git apply -- patches/0001-gitignore-ignore-.externalNativeBuild.patch
echo "git apply ==> patches/0001-gitignore-ignore-.externalNativeBuild.patch"
git apply -- patches/0002-gradle-upgrade-build-tool-to-2.2.0-beta2.patch
echo "git apply ==> patches/0002-gradle-upgrade-build-tool-to-2.2.0-beta2.patch"
git apply -- patches/0003-$PARAM_TARGET-enable-debugging-with-LLDB.patch
echo "git apply ==> patches/0003-$PARAM_TARGET-enable-debugging-with-LLDB.patch"
;;
esac
}

patch_disable () {
PARAM_TARGET=$1
case "$PARAM_TARGET" in
armv5|armv7a|arm64|x86|x86_64)
git apply -R patches/0003-$PARAM_TARGET-enable-debugging-with-LLDB.patch
echo "git apply reverse ==> patches/0003-$PARAM_TARGET-enable-debugging-with-LLDB.patch"
git apply -R patches/0002-gradle-upgrade-build-tool-to-2.2.0-beta2.patch
echo "git apply reverse ==> patches/0002-gradle-upgrade-build-tool-to-2.2.0-beta2.patch"
git apply -R patches/0001-gitignore-ignore-.externalNativeBuild.patch
echo "git apply reverse ==> patches/0001-gitignore-ignore-.externalNativeBuild.patch"
;;
esac
}

case "$1" in
armv5|armv7a|arm64|x86|x86_64)
# patch_enable $1
echo "patch apply ==> $1"
patch_enable $1
;;
reverse)
case "$2" in
armv5|armv7a|arm64|x86|x86_64)
echo "patch reverse ==> $2"
patch_disable $2
;;
*)
echo "Usage:"
echo " patch-debugging-with-lldb.sh armv5|armv7a|arm64|x86|x86_64"
echo " patch-debugging-with-lldb.sh reverse armv5|armv7a|arm64|x86|x86_64"
;;
esac
;;
*)
echo "Usage:"
echo " patch-debugging-with-lldb.sh armv5|armv7a|arm64|x86|x86_64"
echo " patch-debugging-with-lldb.sh reverse armv5|armv7a|arm64|x86|x86_64"
;;
esac
22 changes: 22 additions & 0 deletions android/patches/0001-gitignore-ignore-.externalNativeBuild.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From dc4847b1e8ff5d35576f840db59aec0a3d3fc72b Mon Sep 17 00:00:00 2001
From: ctiao <[email protected]>
Date: Mon, 29 Aug 2016 14:48:08 +0800
Subject: [PATCH 1/2] gitignore: ignore ".externalNativeBuild"

---
android/ijkplayer/.gitignore | 1 +
1 file changed, 1 insertion(+)

diff --git a/android/ijkplayer/.gitignore b/android/ijkplayer/.gitignore
index eac8754..2a3badc 100644
--- a/android/ijkplayer/.gitignore
+++ b/android/ijkplayer/.gitignore
@@ -6,3 +6,4 @@
/build
/captures
android-ndk-prof
+.externalNativeBuild
\ No newline at end of file
--
2.7.4 (Apple Git-66)

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 5d70fa0496f9ebfbcfa3786d85c74c690d66781e Mon Sep 17 00:00:00 2001
From: ctiao <[email protected]>
Date: Mon, 29 Aug 2016 14:50:34 +0800
Subject: [PATCH 2/2] gradle: upgrade build-tool to 2.2.0-beta2

---
android/ijkplayer/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/ijkplayer/build.gradle b/android/ijkplayer/build.gradle
index 0de03ec..6132c1d 100644
--- a/android/ijkplayer/build.gradle
+++ b/android/ijkplayer/build.gradle
@@ -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-beta2'

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
--
2.7.4 (Apple Git-66)

139 changes: 139 additions & 0 deletions android/patches/0003-arm64-enable-debugging-with-LLDB.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
From 8f72e4cdcc3c3ef2d5290be4a755943b972d7239 Mon Sep 17 00:00:00 2001
From: ctiao <[email protected]>
Date: Mon, 29 Aug 2016 17:06:00 +0800
Subject: [PATCH] arm64: enable debugging with LLDB

---
android/ijkplayer/ijkplayer-arm64/build.gradle | 20 ++++++++++++---
.../ijkplayer-arm64/src/main/jni/Android.mk | 29 +++++++++++++++++++++-
android/ijkplayer/ijkplayer-example/build.gradle | 16 ++++++------
android/ijkplayer/settings.gradle | 6 ++---
4 files changed, 56 insertions(+), 15 deletions(-)
mode change 120000 => 100644 android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk

diff --git a/android/ijkplayer/ijkplayer-arm64/build.gradle b/android/ijkplayer/ijkplayer-arm64/build.gradle
index a8cbe0c..ccd04e0 100644
--- a/android/ijkplayer/ijkplayer-arm64/build.gradle
+++ b/android/ijkplayer/ijkplayer-arm64/build.gradle
@@ -10,16 +10,30 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
+ externalNativeBuild {
+ ndkBuild {
+ arguments "NDK_APPLICATION_MK:=src/main/jni/Application.mk"
+ abiFilters "arm64-v8a"
+ }
+ }
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
+ debug {
+ debuggable true
+ jniDebuggable true
+ ndk {
+ debuggable true
+ }
+ }
}
- sourceSets.main {
- jniLibs.srcDirs 'src/main/libs'
- jni.srcDirs = [] // This prevents the auto generation of Android.mk
+ externalNativeBuild {
+ ndkBuild {
+ path 'src/main/jni/Android.mk'
+ }
}
}

diff --git a/android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk b/android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk
deleted file mode 120000
index fb30867..0000000
--- a/android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-../../../../ijkplayer-armv7a/src/main/jni/Android.mk
\ No newline at end of file
diff --git a/android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk b/android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk
new file mode 100644
index 0000000..6b53c1f
--- /dev/null
+++ b/android/ijkplayer/ijkplayer-arm64/src/main/jni/Android.mk
@@ -0,0 +1,28 @@
+# copyright (c) 2013 Zhang Rui <[email protected]>
+#
+# This file is part of ijkPlayer.
+#
+# ijkPlayer is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# ijkPlayer is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with ijkPlayer; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+LOCAL_PATH := $(call my-dir)
+
+MY_APP_JNI_ROOT := $(realpath $(LOCAL_PATH))
+MY_APP_PRJ_ROOT := $(realpath $(MY_APP_JNI_ROOT)/..)
+MY_APP_ANDROID_ROOT := $(realpath $(MY_APP_PRJ_ROOT)/../../../..)
+
+MY_APP_FFMPEG_OUTPUT_PATH := $(realpath $(MY_APP_ANDROID_ROOT)/contrib/build/ffmpeg-arm64/output)
+MY_APP_FFMPEG_INCLUDE_PATH := $(realpath $(MY_APP_FFMPEG_OUTPUT_PATH)/include)
+
+include $(call all-subdir-makefiles)
diff --git a/android/ijkplayer/ijkplayer-example/build.gradle b/android/ijkplayer/ijkplayer-example/build.gradle
index 9afe650..77df829 100644
--- a/android/ijkplayer/ijkplayer-example/build.gradle
+++ b/android/ijkplayer/ijkplayer-example/build.gradle
@@ -44,15 +44,15 @@ dependencies {
compile project(':ijkplayer-java')
compile project(':ijkplayer-exo')

- all32Compile project(':ijkplayer-armv5')
- all32Compile project(':ijkplayer-armv7a')
- all32Compile project(':ijkplayer-x86')
-
- all64Compile project(':ijkplayer-armv5')
- all64Compile project(':ijkplayer-armv7a')
+// all32Compile project(':ijkplayer-armv5')
+// all32Compile project(':ijkplayer-armv7a')
+// all32Compile project(':ijkplayer-x86')
+//
+// all64Compile project(':ijkplayer-armv5')
+// all64Compile project(':ijkplayer-armv7a')
all64Compile project(':ijkplayer-arm64')
- all64Compile project(':ijkplayer-x86')
- all64Compile project(':ijkplayer-x86_64')
+// all64Compile project(':ijkplayer-x86')
+// all64Compile project(':ijkplayer-x86_64')

// armv5Compile project(':player-armv5')
// armv7aCompile project(':player-armv7a')
diff --git a/android/ijkplayer/settings.gradle b/android/ijkplayer/settings.gradle
index 758234a..c9e72d9 100644
--- a/android/ijkplayer/settings.gradle
+++ b/android/ijkplayer/settings.gradle
@@ -1,7 +1,7 @@
-include ':ijkplayer-armv5', ':ijkplayer-x86_64'
-include ':ijkplayer-armv7a'
+//include ':ijkplayer-armv5', ':ijkplayer-x86_64'
+//include ':ijkplayer-armv7a'
include ':ijkplayer-arm64'
-include ':ijkplayer-x86'
+//include ':ijkplayer-x86'

include ':ijkplayer-java'
include ':ijkplayer-exo'
--
2.7.4 (Apple Git-66)

Loading

0 comments on commit 49d4065

Please sign in to comment.