Ich versuche, das Android Studio zu meiner Hauptentwicklungs-IDE für Java UND C/C++ Code zu machen. Ich möchte nativen Code debuggen können.Android Gradle ndk jni mit externer Bibliothek und nativem Debugging (ARToolkit)
In diesem Fall versuche ich ARToolkit5 als eine Bibliothek zu verwenden.
Aufgrund einiger Beispiele im ARToolkit5 habe ich diese Build-Datei.
Ich habe diese Android.mk
Datei
MY_LOCAL_PATH := $(call my-dir)
LOCAL_PATH := $(MY_LOCAL_PATH)
# Pull ARToolKit into the build
include $(CLEAR_VARS)
ARTOOLKIT_DIR := $(MY_LOCAL_PATH)/../../../../../artoolkit5/android
ARTOOLKIT_LIBDIR := $(call host-path, $(ARTOOLKIT_DIR)/obj/local/$(TARGET_ARCH_ABI))
define add_artoolkit_module
include $(CLEAR_VARS)
LOCAL_MODULE:=$1
LOCAL_SRC_FILES:=lib$1.a
include $(PREBUILT_STATIC_LIBRARY)
endef
ARTOOLKIT_LIBS := ar2 kpm util eden argsub_es armulti ar aricp jpeg arvideo
LOCAL_PATH := $(ARTOOLKIT_LIBDIR)
$(foreach module,$(ARTOOLKIT_LIBS),$(eval $(call add_artoolkit_module,$(module))))
LOCAL_PATH := $(MY_LOCAL_PATH)
# Android arvideo depends on CURL.
CURL_DIR := $(ARTOOLKIT_DIR)/jni/curl
CURL_LIBDIR := $(call host-path, $(CURL_DIR)/libs/$(TARGET_ARCH_ABI))
define add_curl_module
include $(CLEAR_VARS)
LOCAL_MODULE:=$1
#LOCAL_SRC_FILES:=lib$1.so
#include $(PREBUILT_SHARED_LIBRARY)
LOCAL_SRC_FILES:=lib$1.a
include $(PREBUILT_STATIC_LIBRARY)
endef
#CURL_LIBS := curl ssl crypto
CURL_LIBS := curl
LOCAL_PATH := $(CURL_LIBDIR)
$(foreach module,$(CURL_LIBS),$(eval $(call add_curl_module,$(module))))
LOCAL_PATH := $(MY_LOCAL_PATH)
include $(CLEAR_VARS)
# ARToolKit libs use lots of floating point, so don't compile in thumb mode.
LOCAL_ARM_MODE := arm
LOCAL_PATH := $(MY_LOCAL_PATH)
LOCAL_MODULE := ndkDebugModule
LOCAL_SRC_FILES := nftSimple.cpp ARMarkerNFT.c trackingSub.c
# Make sure DEBUG is defined for debug builds. (NDK already defines NDEBUG for release builds.)
ifeq ($(APP_OPTIM),debug)
LOCAL_CPPFLAGS += -DDEBUG
endif
LOCAL_C_INCLUDES += $(ARTOOLKIT_DIR)/../include/android $(ARTOOLKIT_DIR)/../include
LOCAL_LDLIBS += -llog -lGLESv1_CM -lz
LOCAL_WHOLE_STATIC_LIBRARIES += ar
LOCAL_STATIC_LIBRARIES += ar2 kpm util eden argsub_es armulti aricp jpeg arvideo cpufeatures
#LOCAL_SHARED_LIBRARIES += $(CURL_LIBS)
LOCAL_STATIC_LIBRARIES += $(CURL_LIBS)
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures)
Dieser Build ordnungsgemäß funktioniert. Jetzt versuche ich dies in die android experimentelle Gradel-Datei zu konvertieren, um es debuggen zu können. Nun jetzt ich habe diesen Zustand:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.3"
defaultConfig.with {
applicationId = "com.nomad5.ndkdebug"
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "0.1"
}
}
/*
* native build settings
*/
android.ndk {
moduleName = "ndkDebugModule"
cppFlags.add("-I./../../../../../artoolkit5/include/ ")
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
debug {
debuggable = true
ndk.with {
debuggable = true
}
}
}
}
/**
* The android native sources
*/
android.sources.main {
jni {
exportedHeaders {
srcDirs = [arRoot.absolutePath + "/include",
arRoot.absolutePath + "/android/jni/curl/include"]
}
source {
/* we set this to NOT automatically compile everything */
srcDirs = ["src/main"]
include "jni/nativeCodeA.cpp"
include "jni/nativeCodeB.cpp"
}
dependencies {
library "lib_ar2" linkage "static"
library "lib_kpm" linkage "static"
library "lib_util" linkage "static"
library "lib_eden" linkage "static"
library "lib_argsub_es" linkage "static"
library "lib_armulti" linkage "static"
library "lib_ar" linkage "static"
library "lib_aricp" linkage "static"
library "lib_jpeg" linkage "static"
library "lib_arvideo" linkage "static"
library "lib_cpufeatures" linkage "static"
library "lib_curl" linkage "static"
}
}
jniLibs {
source {
srcDirs = [arRoot.absolutePath + "/include",
arRoot.absolutePath + "/android/jni/curl/include"]
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':aRBaseLib')
compile 'com.android.support:appcompat-v7:23.4.0'
}
Das Problem mit dem gradle NDK Build ist, dass in meinen Dateien (nativeCodeA.cpp
zum Beispiel) alle einschließt, die in ../../../../../artoolkit5/android
sind, werden nicht gefunden. So werden alle
#include <AR/ar.h>
#include <AR/arMulti.h>
#include <AR/video.h>
...
nicht gefunden.
Wie kann ich einen Ordner hinzufügen, um die advanced ndk Build wie LOCAL_C_INCLUDES
tut dies im Makefile. Und wie kann ich bestimmte Dateien im Makefile wie LOCAL_SRC_FILES
kompilieren. (Wie gradle die Dateien nicht kennt, auch wenn nicht diejenigen, die explizite Angabe?)
By the way i
bin mitdistributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
mit
'com.android.tools.build:gradle-experimental:0.4.0'
nur eine Vermutung aussehen, aber das Projekt Arbeitsverzeichnis wahrscheinlich anders bei den verschiedenen Build-Systemen. Um dies zu überprüfen, ändern Sie Ihre relativen Pfad (e) zu absoluten Pfad (en). Wenn dies funktioniert, versuchen Sie, die Anzahl der '../' in den relativen Pfaden zu ändern. –
Nun, wie Sie in den Kommentaren sehen, habe ich es auch mit absoluten Pfaden versucht –
Wie hast du die Einstellung ** NDEBUG ** in gradle-experimental? –