Recently engaged in Android audio and video communication chat, module engineering are completed, the need to set up by Cocos the framework of the executable program, in the use of Cocos and third-party static library process encountered some problems, because they are the first contact Cocos, coupled with cocos own problems, engaged in a whole day, And finally it was a mess;
Environment: Eclipse+adt, cocos2d-x-3.5
First, the generation of Cocos New project:
Enter E:\OpenSource\cocos2d-x-3.5\tools\cocos2d-console\bin
hold Shift Key, right-click on the blank, open the command window
using Commands Cocos new created, such as:
Cocos new-pcom.example.mediagame-l cpp-d E:/codespace/avmeidagame ProjectName
Note: If the prompt Cocos command does not exist, first run the setup.py file under the root directory (first you need to hold down python.exe) or open the file directly, add the appropriate environment variable at once, and then restart the explorer process to make the environment variable effective.
Second, load the static library
Load the static library (c + +, interface Class), which is also based on Cocos Development, and eventually generate a. A file, the process is no longer a statement, 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
In the application class code to inherit a parent class in the static library, in the NDK compilation process to report that the parent class member function is not implemented, the problem is obvious that the static library is not properly loaded successfully caused by the use of the following methods:
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 add this temporary static library to the appropriate location below
Local_whole_static_libraries + = Clientpublic_static
At this point the compilation will be OK.
Iii. Eclipse Debug Run crash
During debugging run the problem of inexplicable crash, Cocos code I just let the app class inherited a static library of a parent class, there is no reason to crash Ah, just started also because there is no doubt cocos own generated code, so also wasted a lot of time Ah, Finally through the ADB crawl crash log to see the program crash point in the Cocos generated code HelloWorldScene.cpp file using an obsolete interface getcontentsize (), debugging found that the interface returned by the value of an invalid value, resulting in the program layout is invalid, the program crashes.
Label->setposition (VEC2 (origin.x + VISIBLESIZE.WIDTH/2,
ORIGIN.Y + visiblesize.height-label->getcontentsize (). height));
The code here can be changed by yourself. This interface is really deceptive Ah!
The following is a way of pasting adb into the crash log and viewing the crash point through Ndk-stack:
1, start adb (D:\adt-bundle-windows\sdk\platform-tools), enter ADB logcat >d:\crash.log
2, start the apk via Eclipse, press CTRL + C in the ADB-initiated cmd after the crash, stop the output
3, Start Ndk-stack (path D:\android-ndk-r9d)
The command format is: ndk-stack-dmup d:\crash.log-sym obj file path
The obj file path is Proj.android\obj\local\armeabi or armeabi-v7a in the Cocos Self-built project directory
Ndk-stack output is recommended for output to a text file, so it looks more convenient than in CMD
The command format is: ndk-stack-dmup d:\crash.log-sym obj file path >d:\crash_debug.log
This article is from the "Big bro" blog, make sure to keep this source http://cto521.blog.51cto.com/9652841/1703098
Eclipse+adt using third-party static libraries and cocos2d issues summary