美文网首页
Android 项目打包环境快速搭建

Android 项目打包环境快速搭建

作者: 五月笙 | 来源:发表于2021-08-10 09:42 被阅读0次

    基本信息

    当前操作系统信息如下:

    uname -a
    Linux remer 4.15.0-118-generic #119-Ubuntu SMP Tue Sep 8 12:30:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
    
    cat /etc/issue
    Ubuntu 18.04.4 LTS \n \l
    

    环境配置

    curl -s "https://get.sdkman.io" | bash
    source "$HOME/.sdkman/bin/sdkman-init.sh"
    sdk version
    ==== BROADCAST =================================================================
    * 2020-11-10: kscript 3.0.2 available on SDKMAN!
    * 2020-11-10: kscript 3.0.1 available on SDKMAN!
    * 2020-11-10: btrace 2.0.3 available on SDKMAN! https://github.com/btraceio/btrace/releases/download/v2.0.3/btrace-2.0.3-sdkman-bin.zip
    ================================================================================
    
    SDKMAN 5.9.1+575
    

    使用SDKMAN安装JDK:

    # 查看jdk版本
    sdk ls java
    # 选择所要安装的版本
    sdk install java 8.0.272-zulu
    Installing: java 8.0.272-zulu
    Done installing!
    
    Setting java 8.0.272-zulu as default.
    

    查看安装结果:

    java -version
    openjdk version "1.8.0_272"
    OpenJDK Runtime Environment (build 1.8.0_272-8u272-b10-0ubuntu1~18.04-b10)
    OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)
    

    安装android SDK 工具

    cd /opt/services
    curl https://dl.google.com/android/archives/android-sdk-linux_x86-1.6_r1.tgz > android-sdk-linux_x86-1.6_r1.tgz
    tar -zvxf android-sdk-linux_x86-1.6_r1.tgz
    curl https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip > cmdline-tools.zip
    unzip cmdline-tools.zip
    
    # 创建目录
    cd android-sdk-linux_x86-1.6_r1
    mkdir -p cmdline-tools/latest
    mv ../cmdline-tools/* cmdline-tools/latest
    

    环境变量

     vim ~/.bash_profile
    # android
    export ANDROID_HOME=/opt/services/android-sdk-linux_x86-1.6_r1
    export PATH=$ANDROID_HOME/tools:$PATH
    export PATH=$ANDROID_HOME/platform-tools:$PATH
    export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$PATH
    source ~/.bash_profile
    

    SDK版本

    安装指定android sdk 版本

    sdkmanager "platform-tools" "platforms;android-24"
    sdkmanager "build-tools;25.0.2"
    

    打包

    cd /opt/sites/
    git clone ssh://git@gitlab.zeaho.com:10133/android/gongchengbing-v2.git
    ./gradlew -Pmarket=markets.txt clean apkRelease
    

    输出目录

    ls -l ./build/channelApks/
    
    gongchengbing-v2_189store_4.5.5.apk   gongchengbing-v2_appgionee_4.5.5.apk  gongchengbing-v2_gcbmobile_4.5.5.apk  gongchengbing-v2_huawei_4.5.5.apk  gongchengbing-v2_miui_4.5.5.apk      gongchengbing-v2_oppomobile_4.5.5.apk  gongchengbing-v2_uc_4.5.5.apk
    gongchengbing-v2_360mobile_4.5.5.apk  gongchengbing-v2_baidu_4.5.5.apk      gongchengbing-v2_gcbothers_4.5.5.apk  gongchengbing-v2_lenovo_4.5.5.apk  gongchengbing-v2_MMonline_4.5.5.apk  gongchengbing-v2_samsung_4.5.5.apk     gongchengbing-v2_vivo_4.5.5.apk
    gongchengbing-v2_anzhi_4.5.5.apk      gongchengbing-v2_flyme_4.5.5.apk      gongchengbing-v2_gcbweb_4.5.5.apk     gongchengbing-v2_letv_4.5.5.apk    gongchengbing-v2_myapp_4.5.5.apk     gongchengbing-v2_smartisan_4.5.5.apk   gongchengbing-v2_wostore_4.5.5.apk
    

    其他

    打包渠道配置文件:

    vim markets.txt
    
    #前面是渠道名称,后面是渠道的说明注释
    gcbweb
    gcbmobile
    gcbothers
    baidu
    360mobile
    uc
    myapp
    miui
    huawei
    flyme
    vivo
    lenovo
    smartisan
    oppomobile
    smartisan
    anzhi
    letv
    MMonline
    samsung
    appgionee
    189store
    wostore
    

    相关文章

      网友评论

          本文标题:Android 项目打包环境快速搭建

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