Cocos2dxActivity.java中的onLoadNativeLibraries下读取AndroidManifest下配置的Meta值后进行.so库的加载
- <Meta-data android:name="android.app.lib_name"
- android:value="cocos2dcpp" />
- protected void onLoadNativeLibraries() {
- try {
- ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),PackageManager.GET_Meta_DATA);
- Bundle bundle = ai.MetaData;
- String libName = bundle.getString("android.app.lib_name");
- System.loadLibrary(libName);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
java.lang.UnsatisfiedLinkError: dlopen failed:unknown reloc type 160
from:
http://developer.adca.sh/article/plugins-android/cocos/1-0-0-cocos/cocos2d-x/
In case you set up your environment withanother version of NDKthan the recommended one (r9d) and got an error on launching the app:
2 |
unknown reloc type 160 |
You can try modifying the~/Projects/MyGame/cocos2d/plugin/protocols/proj.android/jni/Application.mk
file with the following:
APP_STL := c++_static |
4 | APP_STL := gnustl_static |
- # from:
- APP_STL := c++_static
- # to:
- APP_STL := gnustl_static
- NDK_TOOLCHAIN_VERSION=clang
- APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
- APP_LDFLAGS := -latomic
- TARGET_cpu_API := armeabi
- APP_ABI := armeabi
- APP_DEBUG := $(strip $(NDK_DEBUG))
- ifeq ($(APP_DEBUG),1)
- APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
- APP_OPTIM := debug
- else
- APP_CPPFLAGS += -DNDEBUG
- APP_OPTIM := release
- endif