Android多渠道SDK开发心得(4)——多渠道sdk的开发与构建

转载请注明出处:http://blog.csdn.net/u011370390/article/details/78636574

  网上关于apk多渠道开发有很多说明,但关于sdk的则少的可怜,在开发过程中遇到问题时、多数时间也就只能参考外文资料及自己琢磨。

一.sdk多渠道构建

1.apk多渠道构建

官方文档

2.sdk单渠道构建

  与apk多渠道开发类似,sdk也需要先指定productFlavors,首先新建两个渠道baidu和alibaba
sdk/build.gradle

android {
    ...
    productFlavors {
        baidu{}
        alibaba{}
    }
    ...
}

指定完后同步gradle,马上就会报错

v Gradle 'aar' project refresh failed
    Error:Could not get unknown property 'generateReleaseAssets' for project ':sdk' of type org.gradle.api.Project.

‘generateReleaseAssets’这个task找不到,这可是在配置sdk多渠道开发前,fat-aar.gradle中合并assets文件的task,怎么会找不到呢?

        ...
        // Merge Assets
        generateReleaseAssets.dependsOn embedAssets
        embedAssets.dependsOn prepareReleaseDependencies
        ...

于是将sdk中该productFlavors代码块注释,在app中添加试试
app/build.gradle

android {
    ...
    productFlavors {
        baidu{}
        alibaba{}
    }
    ...
}

同步成功后,在命令后下输出一下命令:

gradle task

会发现好多task中都带有”Baidu”或”Alibaba”这两个渠道名称,

> Task :tasks 

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for each variant.
sourceSets - Prints out all the source sets defined in this project.

Build tasks
-----------
assemble - Assembles all variants of all applications and secondary packages.
assembleAlibaba - Assembles all Alibaba builds.
assembleAndroidTest - Assembles all the Test applications.
assembleBaidu - Assembles all Baidu builds.
assembleDebug - Assembles all Debug builds.
assembleRelease - Assembles all Release builds.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
clean - Deletes the build directory.
cleanBuildCache - Deletes the build cache directory.
compileAlibabaDebugAndroidTestSources
compileAlibabaDebugSources
compileAlibabaDebugUnitTestSources
compileAlibabaReleaseSources
compileAlibabaReleaseUnitTestSources
compileBaiduDebugAndroidTestSources
compileBaiduDebugSources
compileBaiduDebugUnitTestSources
compileBaiduReleaseSources
compileBaiduReleaseUnitTestSources
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
extractDebugAnnotations - Extracts Android annotations for the debug variant into the archive file
extractReleaseAnnotations - Extracts Android annotations for the release variant into the archive file
mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests.

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'aar'.
components - Displays the components produced by root project 'aar'. [incubating]
dependencies - Displays all dependencies declared in root project 'aar'.
dependencyInsight - Displays the insight into a specific dependency in root project 'aar'.
dependentComponents - Displays the dependent components of components in root project 'aar'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'aar'. [incubating]
projects - Displays the sub-projects of root project 'aar'.
properties - Displays the properties of root project 'aar'.
tasks - Displays the tasks runnable from root project 'aar' (some of the displayed tasks may belong to subprojects).

Install tasks
-------------
installAlibabaDebug - Installs the DebugAlibaba build.
installAlibabaDebugAndroidTest - Installs the android (on device) tests for the AlibabaDebug build.
installBaiduDebug - Installs the DebugBaidu build.
installBaiduDebugAndroidTest - Installs the android (on device) tests for the BaiduDebug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAlibabaDebug - Uninstalls the DebugAlibaba build.
uninstallAlibabaDebugAndroidTest - Uninstalls the android (on device) tests for the AlibabaDebug build.
uninstallAlibabaRelease - Uninstalls the ReleaseAlibaba build.
uninstallAll - Uninstall all applications.
uninstallBaiduDebug - Uninstalls the DebugBaidu build.
uninstallBaiduDebugAndroidTest - Uninstalls the android (on device) tests for the BaiduDebug build.
uninstallBaiduRelease - Uninstalls the ReleaseBaidu build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.

Verification tasks
------------------
check - Runs all checks.
connectedAlibabaDebugAndroidTest - Installs and runs the tests for alibabaDebug on connected devices.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedBaiduDebugAndroidTest - Installs and runs the tests for baiduDebug on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintAlibabaDebug - Runs lint on the AlibabaDebug build.
lintAlibabaRelease - Runs lint on the AlibabaRelease build.
lintBaiduDebug - Runs lint on the BaiduDebug build.
lintBaiduRelease - Runs lint on the BaiduRelease build.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
test - Run unit tests for all variants.
testAlibabaDebugUnitTest - Run unit tests for the alibabaDebug build.
testAlibabaReleaseUnitTest - Run unit tests for the alibabaRelease build.
testBaiduDebugUnitTest - Run unit tests for the baiduDebug build.
testBaiduReleaseUnitTest - Run unit tests for the baiduRelease build.
testDebugUnitTest - Run unit tests for 
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值