android+libgdx+教程,Android ndk + libgdx

问题

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值