cocos2dx 3.9 升级 3.17

1.更改环境变量,使用cocos2dx3.17

2.想新工程中添加三方库

3.跟新工程头文件引用

4.openssl冲突修改三方库的函数引用中cocos自带的库

5.添加android app/android.mk 头文件引用,注意相对路径

6.android编译错误:

cocos compile --compile-script 0 -m release -p android
 /Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/jni/../../../Classes/Foxair/atomic.cpp:15:10: fatal error: 'sys/atomics.h' file not found
  #include 
           ^~~~~~~~~~~~~~~
  1 error generated.
  make: *** [/Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2dlua_shared/__/__/__/Classes/Foxair/atomic.o] Error 1
  make: *** Waiting for unfinished jobs....

ndk低版本中sys/atomics.h被stdatomics.h替换,使用其中函数重写:

#include 
int atomicDecrement(volatile int* t) {
    __sync_fetch_and_sub(t, 1);
    return *t;
}
int atomicIncrement(volatile int* t) {
    __sync_fetch_and_add(t, 1);
    return *t;
}
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)

7.

  /Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/jni/../../../Classes/Foxair/game_connection.cpp:24:10: fatal error: 'sys/timeb.h' file not found
  #include 
           ^~~~~~~~~~~~~
  1 error generated.
  make: *** [/Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2dlua_shared/__/__/__/Classes/Foxair/game_connection.o] Error 1
  make: *** Waiting for unfinished jobs....
#include 

struct timeval tp;
gettimeofday(&tp, NULL);
//当前时间
long long now = (long long)tp.tv_sec * 1000 + (long long)tp.tv_usec;
Mutex::ScopedLock timestampLock(m_timestampMutex);

 

 

配置要求:

android-ndk-r16b

android-sdk-macosx

# Android SDK version that will be used as the compile project
PROP_COMPILE_SDK_VERSION=27

# Android SDK version that will be used as the earliest version of android this application can run on
PROP_MIN_SDK_VERSION=14

# Android SDK version that will be used as the latest version of android this application has been tested on
PROP_TARGET_SDK_VERSION=27

# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=27.0.1

# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
PROP_APP_ABI=armeabi-v7a

# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=ndk-build

android studio 3.3

编译模式:release
使用 Android Studio 工程:/Users/admin/code/client/project_wly2_lua_client/frameworks/runtime-src/proj.android
配置文件 '/Users/admin/code/client/project_wly2_lua_client/frameworks/runtime-src/proj.android/build-cfg.json' 不存在或者已损坏。

修改.cocos_project文件

你可能感兴趣的:(【COCOS】)