In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "eclipse+ADT how to use third-party static library", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "eclipse+ADT how to use third-party static library" this article bar.
Environment: eclipse+ADT, cocos2d-x-3.5
1. Creation of new cocos projects:
Enter E:\OpenSource\cocos2d-x-3.5\tools\cocos2d-console\bin
Hold down shift key, right click blank space, open command window
Use the command cocos new to create, for example:
cocos new -p com.example.mediagame -l cpp -d E:/CodeSpace/AVMeidaGame ProjectName
Note: If the prompt cocos command does not exist, please run the setup.py file in the root directory first (you need to hold down python.exe first) or directly open this file, add the corresponding environment variables at once, and then restart the explorer process to make the environment variables take effect.
II. Loading static libraries
Load static library (C++, interface class), the static library is also based on cocos development, and finally generate a.a file, the process is no longer repeated, I first use the following parameters (Android.mk):
LOCAL_SRC_FILES:= $(LOCAL_PATH)\libs\libClientPublic.a
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES := ClientPublic
Inherit a parent class in the static library in the APP class code. In the ndk compilation process, the member function of the parent class is reported not to be implemented. The problem is obviously caused by the static library not being loaded correctly. After checking, the following methods can be used:
Before include $(CLEAR_VARS), add the following command to generate a temporary static library
LOCAL_MODULE:= ClientPublic_static
LOCAL_MODULE_FILENAME := libClientPublic_static
LOCAL_SRC_FILES:=$(LOCAL_PATH)\libs\libClientPublic.a
include $(PREBUILT_STATIC_LIBRARY)
Then load this temporary static library by adding it in the appropriate position below
LOCAL_WHOLE_STATIC_LIBRARIES += ClientPublic_static
The compilation is OK.
Third, eclipse debugging run crash
In the debugging process, there is an inexplicable crash problem. The code of cocos itself just makes the APP class inherit a parent class in the static library. There is no reason to crash. At first, it is also because there is no doubt that the code generated by cocos itself is generated. So it is also a waste of a lot of time. Finally, through adb grab crash log, I saw the program crash point. In the code generated by Cocos HelloWorldScene.cpp file, the interface getContentSize () has been abandoned. Debugging found that the interface returned invalid values, resulting in program layout until invalid, program crash.
label->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
The code here can be modified by yourself. This interface was really deceptive!
Here's how adb can grab crash logs and view crash points via ndk-stack:
1. Start adb (D:\adt-bundle-windows\sdk\platform-tools), enter adb logcat >d:\crash.log
2, start apk via eclipse, press ctrl+c in cmd started by adb after crash, stop output
3, Start ndk-stack (path D:\android-ndk-r9d)
Command format: ndk-stack -dmup d:\crash.log -sym obj file path
obj file path is proj.android\obj\local\armeabi or armeabi-v7a under COCOS self-built project directory
ndk-stack output is recommended for output to a text file, which looks more convenient than in cmd
Command format: ndk-stack -dmup d:\crash.log -sym obj file path>d:\crash_debug.log
That's all for Eclipse+ADT: How to use third-party static libraries. Thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.