美文网首页
cocos2dx v3.17安卓编译

cocos2dx v3.17安卓编译

作者: 偏分武士 | 来源:发表于2020-09-01 14:18 被阅读0次

    0. 编译方式:

    gradle + ndk(没有使用cmake)

    1 )配置NDK_ROOT


    image.png
    1. 配置ANDROID_SDK_ROOT


      image.png

    1. 使用android studio 管理android sdk

    由于网络问题, 需要先给android studio配置代理

    1) 配置sdk下载代理

    mirrors.neusoft.edu.cn:80


    image.png

    下载SDK

    image.png

    2) android studio同步时, 会自动下载对应版本的gradle, 同样因为网络问题容易超时失败

    gradle的代理需要单独配置:
    需要在C:\Users\xxxx.gradle文件夹下放入下面两个文件

    gradle.properties

    systemProp.http.proxyHost=mirrors.neusoft.edu.cn
    systemProp.http.proxyPort=80
    systemProp.https.proxyHost=
    systemProp.https.proxyPort=80
    

    init.gradle

    allprojects {
        repositories {
            maven {
                url 'https://maven.aliyun.com/repository/public/'
            }
            maven {
                url 'https://maven.aliyun.com/repository/google/'
            }
    
            all { ArtifactRepository repo ->
                if (repo instanceof MavenArtifactRepository) {
                    def url = repo.url.toString()
    
                    if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo.maven.org/maven2') 
                        || url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')
                        || url.startsWith('https://maven.google.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/')) {
                        //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                        remove repo
                    }
                }
            }
        }
    
        buildscript {
            repositories {
                maven{ url 'https://maven.aliyun.com/repository/public/'}
                maven{ url 'https://maven.aliyun.com/repository/google/'}
    
                all { ArtifactRepository repo ->
                    if (repo instanceof MavenArtifactRepository) {
                        def url = repo.url.toString()
                        if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')
                             || url.startsWith('https://dl.google.com/dl/android/maven2/')) {
                            //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                            remove repo
                        }
                    }
                }
            }
        }
    
    }
    

    2. 使用android studio编译apk

    image.png

    3. 也可以使用命令行编译apk

    set NDK_ROOT=%NDK_R16B%
    set COCOS=./frameworks/cocos2d-x/tools/cocos2d-console/bin/cocos.bat
    
    @rem debug
    %COCOS%  compile -p android -m debug -j 7 --ap android-28 --build-type ndk-build
    @rem release
    %COCOS%  compile -p android -m release -j 7 --ap android-28 --build-type ndk-build --compile-script 0
    

    相关文章

      网友评论

          本文标题:cocos2dx v3.17安卓编译

          本文链接:https://www.haomeiwen.com/subject/xelvsktx.html