欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

linux下Android打包环境搭建

程序员文章站 2022-03-26 10:11:07
linux下Android打包环境搭建1. 所需软件安装包jdk安装包下载:链接:https://pan.baidu.com/s/1aUZyK3wfMmzB3g8wihUcEQ 提取码:0sdf fullter安装包下载链接:https://pan.baidu.com/s/1exH3-ibS5AaliB8tf2eRxw 提取码:om41 gradle安装包下载wget https://downloads.gradle-dn.com/distributions/gradle-5.6.4-...

linux下Android打包环境搭建

1. 所需软件安装包

jdk安装包下载:
链接:https://pan.baidu.com/s/1aUZyK3wfMmzB3g8wihUcEQ 
提取码:0sdf 

fullter安装包下载
链接:https://pan.baidu.com/s/1exH3-ibS5AaliB8tf2eRxw 
提取码:om41 

gradle安装包下载
wget https://downloads.gradle-dn.com/distributions/gradle-5.6.4-all.zip

SDK下载安装
链接:https://pan.baidu.com/s/1rRod594rKzre5y0zrZo3Jg 
提取码:85xu 

2. 安装jdk

下载jdk安装包到/usr/local/

cd /usr/local/
tar zxvf jdk-8u191-linux-x64.tar.gz

3. 安装git

yum -y install git unzip zip
#下载版本过低不支持,需要升级
yum -y install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
yum -y update git
git --version

4. 安装SDK

下载SDK安装包到/usr/local/

cd /usr/local/
unzip commandlinetools-linux-6200805_latest.zip -d /usr/local
mkdir -p /usr/local/sdk
cd /usr/local/cmdline-tools/bin
./sdkmanager --list --sdk_root=/usr/local/sdk  							 #显示可安装包
./sdkmanager --install "platforms;android-29" --sdk_root=/usr/local/sdk  #安装android-29
./sdkmanager --install "platform-tools" --sdk_root=/usr/local/sdk        #安装platform-tools
./sdkmanager --install "build-tools;29.0.3" --sdk_root=/usr/local/sdk    #安装build-tools
./sdkmanager --install "cmdline-tools;latest" --sdk_root=/usr/local/sdk  #安装cmdline-tools

5. 安装flutter

cd /usr/local
git clone https://github.com/flutter/flutter.git -b stable

6. 安装gradle

cd /usr/local
wget https://downloads.gradle-dn.com/distributions/gradle-5.6.4-all.zip
unzip gradle-5.6.4-all.zipvim  

7. 添加环境变量

vim /etc/profile

添加

export JAVA_HOME=/usr/local/jdk1.8.0_191
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export ANDROID_HOME=/usr/local/sdk
export FLUTTER_HOME=/usr/local/flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export GRADLE_HOME=/usr/local/gradle-5.6.4
export PATH=$PATH:$GRADLE_HOME/binPATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:${ANDROID_HOME}/build-tools/29.0.3:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${FLUTTER_HOME}/bin:${PATH}

重置环境变量

source /etc/profile

8. 验证环境

java -version
sdkmanager --version
gradle -version

9. 更新SDK

flutter doctor --android-licenses

9. 创建一个工程

mkdir -p /opt/project/demo
cd /opt/project
fullter create demo

10. flutter框架Android打包成apk

cd /opt/project/demo
flutter build apk

11. 正常Android工程打包apk

#例如网上下载一工程test_android
cd test_android
./gradlew :easy-preference:assembleRelease
gradle assembleRelease

本文地址:https://blog.csdn.net/weixin_40668374/article/details/110529948

相关标签: linux apk android