【发布时间】:2016-10-03 17:29:55
【问题描述】:
我试图通过插入日志消息来调试 JNI C 函数,但我无法让它工作。我尝试了所有方法,但出现此错误:
Error:(61) undefined reference to `__android_log_write'
在这一行:__android_log_write(prio, sTag, buf);
这是我的 android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Here we give our module name and source file(s)
LOCAL_MODULE := engine
LOCAL_SRC_FILES := engine.c common.c effiindexb.c alertsmanager.c
LOCAL_CFLAGS += -std=c99
#APP_CFLAGS += -std=c99
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
我有两个文件 .gradle,这是第一个:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig {
applicationId = "com.effidriver"
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 23
}
ndk {
moduleName "engine"
toolchain = 'clang'
CFlags.addAll(['-Wall'])
}
buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
productFlavors {
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
}
dependencies {
compile project(':library')
compile 'com.android.support:support-v4:23.3.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.code.gson:gson:2.2.4'
compile files('libs/TestFlightLib.jar')
compile project(path: ':library')
compile project(path: ':library')
}
这是第二个 .gradle:
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 'Google Inc.:Google APIs:17'
buildToolsVersion = "24.0.0 rc3"
defaultConfig {
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 23
}
buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.0'
}
我正在使用 gradle 实验。classpath 'com.android.tools.build:gradle-experimental:0.7.0'
我真的搜索了整个互联网,但我没有找到一个好的解决方案,希望我能在这里找到......谢谢!
【问题讨论】:
标签: android c android-studio android-ndk java-native-interface