在包含下划线的Android包名称中调用JNI函数 [英] Invoking JNI functions in Android package name containing underscore

查看:276
本文介绍了在包含下划线的Android包名称中调用JNI函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照以下指南使用LAME库在Android中实现MP3编码:
Lame MP3编码器为Android编译
http://developer.samsung.com/android/technical-docs/Porting-and-using-LAME-MP3-on-Android-with-JNI

I am trying to implement MP3 encoding in Android using the LAME library following these guides: Lame MP3 Encoder compile for Android http://developer.samsung.com/android/technical-docs/Porting-and-using-LAME-MP3-on-Android-with-JNI

但是我得到了一个java.lang.UnsatisfiedLinkError,我认为可能是因为我的包名包含一个下划线,它将其解释为句号。

However I am getting a java.lang.UnsatisfiedLinkError which I believe might be due to the fact that my package name contains an underscore which it interprets as a full stop .

查看下面的代码可能是这个问题,我该如何解决这个问题。或者是否有其他原因导致这种情况。在此先感谢您的帮助。

Looking at my code below is this likely this issue and how do I get around that. Or is there something else causing this. Thanks in advance for any help.

Record.java

package co.uk.ing_simmons.aberdeensoundsites;

public class Record extends Activity implements OnClickListener {

static {
    System.loadLibrary("mp3lame");
}

private native void initEncoder(int numChannels, int sampleRate, int bitRate, int mode, int quality);

private native void destroyEncoder();

private native int encodeFile(String sourcePath, String targetPath);

[.....]
}

wrapper.c

void Java_co_uk_ing_simmons_aberdeensoundsites_Record_initEncoder(JNIEnv *env,
        jobject jobj, jint in_num_channels, jint in_samplerate, jint in_brate,
        jint in_mode, jint in_quality) {
[....]

完整日志猫错误

04-17 20:58:36.009: E/AndroidRuntime(26768): FATAL EXCEPTION: main
04-17 20:58:36.009: E/AndroidRuntime(26768): java.lang.UnsatisfiedLinkError: initEncoder
04-17 20:58:36.009: E/AndroidRuntime(26768):    at co.uk.ing_simmons.aberdeensoundsites.Record.initEncoder(Native Method)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at co.uk.ing_simmons.aberdeensoundsites.Record.onCreate(Record.java:79)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.os.Looper.loop(Looper.java:123)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at android.app.ActivityThread.main(ActivityThread.java:3687)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at java.lang.reflect.Method.invokeNative(Native Method)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at java.lang.reflect.Method.invoke(Method.java:507)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-17 20:58:36.009: E/AndroidRuntime(26768):    at dalvik.system.NativeStart.main(Native Method)


推荐答案

您应该使用数字1的下划线。因此,如果您的包名称包含ing_simmons,那么您的JNI将形成如此。

You should follow the underscore with the number 1. So if your package name contains ing_simmons then your JNI would be formed like so.

void Java_co_uk_ing_1simmons_aberdeensoundsites_Record_initEncoder

如果您在通话的任何其他部分有下划线,例如Java文件中的类名或方法名。

This is true also if you have underscores in any other part of the call, such as class name or method name in the Java file.

这篇关于在包含下划线的Android包名称中调用JNI函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆