0

I have source code from a demo app that is involves some native coding. I'd like to integrate some part of that code into my own app.

This is how the code is structured:

app/
    java/
        com.demoUser/
            caffe_android_demo/
                MainActivity
            caffe_android_lib/
                CaffeMobile
    jniLibs/
        libcaffe_jni.so

Apparantly there are some parts in the native code which are specific towards the the app's package name, like in caffe_jni.cpp:

JNIEXPORT void JNICALL
Java_com_demoUser_caffe_1android_1lib_CaffeMobile_extractFeatures(
someArgs...) {
...
}

How can I refactor those names such that it can be called from my app com.myUsername? Or is there another way to include code from another app in android studio?

4

1 回答 1

1

本机代码在您的 demoClassName 类中调用 java 方法 demoMethodName()。确保你已经在你的类中定义了方法。

对于第二部分,您可以按照以下规则更改函数名称

Prepend Java_ to the function name.

Describe the filepath relative to the top-level source directory.

Use underscores in place of forward slashes.

Omit the .java file extension.

After the last underscore, append the function name.

在您的情况下,使用您的用户名更改 demoUser

JNIEXPORT void JNICALL
Java_com_myUsername_caffe_1android_1lib_CaffeMobile_extractFeatures(
someArgs...) {
   ...
}
于 2016-04-28T08:59:39.343 回答