更改程序包名称android清单会导致JNI问题 [英] Changing package name android manifest causes problems JNI
问题描述
我一直在修改并玩这个项目:
I have been modifying and playing around with this project:
源代码: https://bitbucket.org/viet0904163136/gba-android/src
这是GPLv2许可的Gameboy高级仿真器.一切正常,直到我更改android manifest文件中的packagename为止.
It's a gameboy advance emulator licensed under GPLv2. Every thing works ok until i change the packagename in the android manifest file.
在没有更改软件包名称的情况下,该应用程序可以正常运行.但是,当更改程序包名称时,SDLactivity会退出,并显示以下消息: (我将其重命名为com.gba.emu)
Without the package name changed the app works without a problem. But when the package name is changed the SDLactivity quits with this message: (i renamed it to com.gba.emu)
09-01 12:23:16.409: I/SDL(884): SDL_Android_Init()
09-01 12:23:16.409: W/dalvikvm(884): JNI WARNING: received null jclass
09-01 12:23:16.419: W/dalvikvm(884):in Lorg/libsdl/app/SDLActivity;.nativeInit:()V (GetStaticMethodID)
09-01 12:23:16.419: I/dalvikvm(884): "SDLThread" prio=5 tid=17 NATIVE
09-01 12:23:16.419: I/dalvikvm(884): | group="main" sCount=0 dsCount=0 obj=0x4183fc00 self=0x2a2b6f88
09-01 12:23:16.419: I/dalvikvm(884): | sysTid=1148 nice=0 sched=0/0 cgrp=apps handle=707490776
09-01 12:23:16.479: I/dalvikvm(884): | state=R schedstat=( 4273431 73605592 10 ) utm=0 stm=0 core=0
09-01 12:23:16.589: I/dalvikvm(884): #00 pc 000012fe /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
09-01 12:23:16.700: I/dalvikvm(884): #01 pc 0005fd92 /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+33)
09-01 12:23:16.700: I/dalvikvm(884): #02 pc 00053e28 /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+395)
09-01 12:23:16.700: I/dalvikvm(884): #03 pc 00053e96 /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
09-01 12:23:16.700: I/dalvikvm(884): #04 pc 000385c0 /system/lib/libdvm.so
09-01 12:23:16.700: I/dalvikvm(884): #05 pc 00038896 /system/lib/libdvm.so
09-01 12:23:16.709: I/dalvikvm(884): #06 pc 0003985c /system/lib/libdvm.so
09-01 12:23:16.709: I/dalvikvm(884): #07 pc 0003dbe2 /system/lib/libdvm.so
09-01 12:23:16.709: I/dalvikvm(884): #08 pc 000f3bfa /data/app-lib/com.gba.emu- 1/libmain.so (SDL_Android_Init+549)
09-01 12:23:16.709: I/dalvikvm(884): #09 pc 000a7770 /data/app-lib/com.gba.emu-1/libmain.so (Java_org_libsdl_app_SDLActivity_nativeInit+3)
09-01 12:23:16.709: I/dalvikvm(884): #10 pc 0001dc4c /system/lib/libdvm.so (dvmPlatformInvoke+112)
09-01 12:23:16.739: I/dalvikvm(884): #11 pc 0004dcaa /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+393)
09-01 12:23:16.739: I/dalvikvm(884): #12 pc 000385e0 /system/lib/libdvm.so (dvmCheckCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+7)
09-01 12:23:16.739: I/dalvikvm(884): #13 pc 0004f696 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+181)
09-01 12:23:16.739: I/dalvikvm(884): #14 pc 00027060 /system/lib/libdvm.so
09-01 12:23:16.739: I/dalvikvm(884): #15 pc 0002b580 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
09-01 12:23:16.739: I/dalvikvm(884): #16 pc 0005fcbc /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+291)
09-01 12:23:16.749: I/dalvikvm(884): #17 pc 0005fce6 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+19)
09-01 12:23:16.749: I/dalvikvm(884): #18 pc 00054a6e /system/lib/libdvm.so
09-01 12:23:16.749: I/dalvikvm(884): #19 pc 0000ca58 /system/lib/libc.so (__thread_entry+72)
09-01 12:23:16.749: I/dalvikvm(884): #20 pc 0000cbd4 /system/lib/libc.so (pthread_create+208)
09-01 12:23:16.749: I/dalvikvm(884): at org.libsdl.app.SDLActivity.nativeInit(Native Method)
09-01 12:23:16.749: I/dalvikvm(884): at org.libsdl.app.SDLMain.run(SDLActivity.java:704)
09-01 12:23:16.759: I/dalvikvm(884): at java.lang.Thread.run(Thread.java:841)
09-01 12:23:16.759: E/dalvikvm(884): VM aborting
src文件夹中有2个软件包("com.van.gba"和"org.libsdl.app"). jni中的所有内容都指向org.libsdl.app.清单包名称为com.van.gba
There are 2 packages in the src folder ("com.van.gba" and "org.libsdl.app"). Everything in the jni is pointed to org.libsdl.app. The manifest package name is com.van.gba
当我更改com.van.gba时,它会中断.
when i change com.van.gba it breaks.
所以我想知道是什么引起了这个问题?我找不到jni文件中原始包名称(com.van.gba)的唯一引用.
So i am wondering, what is causing this problem? I can't find a single refrence to the original package name (com.van.gba) in the jni files.
可以通过更改程序包层次结构和android manifest程序包名称来模拟此错误. (均称为com.van.gba).加载gba rom时会发生这种情况.
This error can be simulated by changing the package hierarchy and android manifest package name. (both called com.van.gba) It will occur when loading a gba rom.
(注意:在编译jni之前,请将android.mk文件中的SDL2_image添加到LOCAL_STATIC_LIBRARIES + = zlib png(类似此LOCAL_STATIC_LIBRARIES += zlib png SDL2_image
))
(note: before compiling the jni add SDL2_image to LOCAL_STATIC_LIBRARIES += zlib png ( like this LOCAL_STATIC_LIBRARIES += zlib png SDL2_image
) in the android.mk file under the folder "src")
推荐答案
如果您查看在包org.libsdl.app
中定义了类SDLActivity
的本机方法.如果重命名了SDLActivity
的程序包,则必须重命名 .c 文件中的所有此类功能.
Which defines a native method of class SDLActivity
in package org.libsdl.app
. You must rename all such functions in your .c files if the package of the SDLActivity
is renamed.
另一方面,重命名APK包时无需重命名Java类的包.创建一个小的本地包装" Java类并将所有本机方法移到该类通常也很方便.然后从这个班级叫他们.这对于静态本机方法尤其重要.
On the other hand, there is no need to rename the package of the Java class when you rename the APK package. It is also often convenient to create a small "native wrapper" Java class, and move all native methods to this class; then call them from this class. This is especially relevant for static native methods.
====更新====
这里是软件包名称的另一条硬连接:
Here is another place where the package name is hardwired:
请参见类com.van.gba.SelectGameActivity
String strTempPath = Environment.getExternalStorageDirectory().getAbsolutePath();
strTempPath += "/Android/data/";
strTempPath += SelectGameActivity.this.getPackageName();
File dir = new File(strTempPath);
它正在根据其程序包名称查找某些文件;假设其软件包名称等于APK软件包名称.您的代码中可能还有更多类似的地方.修复它们后,您将能够重命名APK包.
It is looking for some files based on its package name; it assumes that its package name is equal to the APK package name. There are probably more places like this in your code. When you have them fixed, you will be able to rename the APK package.
这篇关于更改程序包名称android清单会导致JNI问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!