ITKeyword,专注技术干货聚合推荐

注册 | 登录

cocos2dx工程部署到android-studio中,build.gradle的写法

u010933209 分享于 2016-01-20

推荐:Cocos2dx之android版本的build.xml驯服记

自己代码目录修改如下 <xml version="1.0" encoding="UTF-8"><project name="HelloCpp" default="help"> <!--自己定义的外部的库的目录 --> <propert

2018阿里云全部产品优惠券(新购或升级都可以使用,强烈推荐)
领取地址https://promotion.aliyun.com/ntms/yunparter/invite.html

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "org.cocos2dx.DobiParkour"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"

        // dex突破65535的限制
        multiDexEnabled true
        // 默认渠道
        manifestPlaceholders = [CHANNEL_VALUE: "Youmi"]

    }

    signingConfigs {
        release {
        }
    }

    buildTypes {
        debug{

        }
        release {
            // 不显示Log
            buildConfigField "boolean", "LOG_DEBUG", "false"
            minifyEnabled false
            zipAlignEnabled true
            // 移除无用的resource文件
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = output.outputFile
                    if (outputFile != null && outputFile.name.endsWith('.apk')) {
                        // 输出apk名称为dobi_v1.0_wandoujia.apk
                        def fileName = "DobiParkour_${variant.productFlavors[0].name}.apk"
                        output.outputFile = new File(outputFile.parent, fileName)
                    }
                }
            }
        }
    }

    sourceSets {
        main {
            //打包.so库
            jniLibs.srcDirs = ['libs']
            //打包cocos2dx的resource资源
            assets.srcDirs= ['assets']
        }
    }

    // 多渠道打包
    productFlavors {
        Youmi {}
        Xindian {}
        Saile {}
        Youyoucun {}
        Kuhua {}
        Sikai {}
        Damengshikong {}
        jimeichuanmei {}
        Dianle {}
        Manleyou {}
        Gude {}
    }
    productFlavors.all { flavor ->
        flavor.manifestPlaceholders = [CHANNEL_VALUE: name]
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar','.so'])
    compile project(':libcocos2dx')
    compile files('libs/alipaysdk.jar')
    compile files('libs/alipaysecsdk.jar')
    compile files('libs/alipayutdid.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/BmobPay_V1.0.2.jar')
    compile files('libs/EAccount_SDK_Android_V3.0.9_build201509091117.jar')
    compile files('libs/fastjson-1.2.5.jar')
    compile files('libs/MobLogCollector.jar')
    compile files('libs/MobTools.jar')
    compile files('libs/open_sdk_r5509.jar')
    compile files('libs/ShareSDK-Core-2.6.3.jar')
    compile files('libs/ShareSDK-QQ-2.6.3.jar')
    compile files('libs/ShareSDK-QZone-2.6.3.jar')
    compile files('libs/ShareSDK-SinaWeibo-2.6.3.jar')
    compile files('libs/ShareSDK-Wechat-2.6.3.jar')
    compile files('libs/ShareSDK-Wechat-Core-2.6.3.jar')
    compile files('libs/ShareSDK-Wechat-Moments-2.6.3.jar')
    compile files('libs/volley.jar')
}

以上写法包含了多渠道打包的方法以及打包.so库和cocos2dx中resources的方法。

推荐:cocos2dx 命令创建各平台工程,并自动打包Android apk的方法

转自:http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_create_a_multi-platform_project_in_one_command_line How to create a multi-platform proje

apply plugin: 'com.android.application'android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "org.cocos2dx.DobiParkour"

相关阅读排行


用户评论

游客

相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。