Android ndk + libgdx

杀马特。学长 韩版系。学妹 提交于 2019-12-11 07:54:36

问题



I have a project in libgdx. I want to add Native Support. When connecting libgdx folder libs are files
\ armeabi \ libgdx.so
\ armeabi \ libandroidgl20.so
\ armeabi-v7a \ libgdx.so
\ armeabi-v7a \ libandroidgl20.so

When I build the libraries My.cpp, folders armeabi and armeabi-v7a overwritten armeabi folder contains only My.so, folder armeabi-v7a becomes empty. An error occurs.

my file Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := My
### Add all source file names to be included in lib separated by a whitespace
LOCAL_SRC_FILES := My.cpp
include $(BUILD_SHARED_LIBRARY)

I know that modify Android.mk, but all my attempts failed. Please tell me how to fix it.


回答1:


The way that works for me after Eclipse Android tools' "add native support" in an already started project (that messed up the thing and removes libgdx's so files after each rebuild).

1.- Make a subdir structure inside "jni" folder to put libgdx's shared libs

  • jni
    • shared
      • libgdx
        • armeabi
          • libandroidgl20.so
          • ligdx.so
        • armeabi-v7a
          • libandroidgl20.so
          • libgdx.so
    • Android.mk
    • Application.mk
    • my_app.cpp

2.- Add the following lines to Android.mk after "LOCAL_PATH := $(call my-dir)"

include $(CLEAR_VARS)
LOCAL_MODULE := gdx
LOCAL_SRC_FILES := shared/libgdx/$(TARGET_ARCH_ABI)/libgdx.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := androidgl20
LOCAL_SRC_FILES := shared/libgdx/$(TARGET_ARCH_ABI)/libandroidgl20.so
include $(PREBUILT_SHARED_LIBRARY)

3.- Add the following lines to Application.mk (if this file doesn't exists, create one in the same folder as Android.mk)

APP_ABI := armeabi armeabi-v7a
APP_MODULES := my_app gdx androidgl20

And that's all, folks!




回答2:


First, you need to explicitly enable both architectures. Create a file Application.mk with the following line:

APP_ABI := armeabi armeabi-v7a

You'll also need to reference the libraries for the linking. Add the following to Android.mk:

LOCAL_SHARED_LIBRARIES += libgdx libandroidgl20  

Second, you need to make the third party libraries available for the build. The guidance is here: Android NDK building - Include LOCAL_SHARED_LIBRARIES?



来源:https://stackoverflow.com/questions/12219966/android-ndk-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!