我试图通过插入日志消息来调试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')
}
这是seconde .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 experimental。classpath 'com.android.tools.build:gradle-experimental:0.7.0'
我真的在网上搜索,我没有得到一个好的解决方案,希望我能在这里找到... Thanx!
答案 0 :(得分:0)
像这样修改你的模块gradle文件ndk块并尝试:
library(microbenchmark)
library(dplyr)
library(data.table)
poo <- read.table(text = '
TRIAL_INDEX RIGHT_PUPIL_SIZE
1 10
1 8
1 6
1 4
1 NA
2 1
2 2
2 NA
2 4
2 5
', header = TRUE, stringsAsFactors = FALSE, na.strings = "NA")
tapply.function <- function(x) {
my.summary <- as.data.frame(do.call("rbind",
tapply(poo$RIGHT_PUPIL_SIZE, poo$TRIAL_INDEX,
function(x) c(index.mean = mean(x, na.rm = TRUE),
index.sd = sd(x, na.rm = TRUE)))))
my.summary$TRIAL_INDEX <- rownames(my.summary)
poo2 <- merge(poo, my.summary, by = 'TRIAL_INDEX')
return(poo2)
}
str(tapply.function(poo))
aggregate.function <- function(x) {
my.summary <- with(poo, aggregate(RIGHT_PUPIL_SIZE, by = list(TRIAL_INDEX),
FUN = function(x) {c( index.mean = mean(x, na.rm = TRUE),
index.sd = sd(x, na.rm = TRUE))}))
my.summary <- do.call(data.frame, my.summary)
colnames(my.summary) <- c('TRIAL_INDEX', 'index.mean', 'index.sd')
poo2 <- merge(poo, my.summary, by = 'TRIAL_INDEX')
return(poo2)
}
str(aggregate.function(poo))
ave.function <- function(x) {
index.mean <- ave(poo$RIGHT_PUPIL_SIZE, poo$TRIAL_INDEX, FUN = function(x) mean(x, na.rm = TRUE))
index.sd <- ave(poo$RIGHT_PUPIL_SIZE, poo$TRIAL_INDEX, FUN = function(x) sd(x, na.rm = TRUE))
poo2 <- data.frame(poo, index.mean, index.sd)
return(poo2)
}
str(ave.function(poo))
dplyr.function <- function(x) {
my.summary <- poo %>%
group_by(TRIAL_INDEX) %>%
summarise(index.mean = mean(RIGHT_PUPIL_SIZE, na.rm = TRUE),
index.sd = sd(RIGHT_PUPIL_SIZE, na.rm = TRUE))
poo2 <- merge(poo, as.data.frame(my.summary), by = 'TRIAL_INDEX')
return(poo2)
}
str(dplyr.function(poo))
data.table.function <- function(x) {
my.summary <- data.frame(setDT(poo)[, .(index.mean = mean(RIGHT_PUPIL_SIZE, na.rm = TRUE),
index.sd = sd(RIGHT_PUPIL_SIZE, na.rm = TRUE)),
.(TRIAL_INDEX)])
poo2 <- merge(poo, my.summary, by = 'TRIAL_INDEX')
return(poo2)
}
str(data.table.function(poo))
# this does not work
microbenchmark( tapply.function(poo),
aggregate.function(poo),
ave.function(poo),
dplyr.function(poo),
data.table.function(poo), times = 1000)