ubuntu20.04配置 mtk android 8.1编译环境

本文主要讲述android 8.1编译环境,android11的应该也可以编译

准备工具
sudo apt-get install geany vim
sudo apt-get install -y python
sudo apt-get install -y samba
sudo dpkg -i /D/Tool/bcompare-4.3.4.24657_amd641.deb

sudo apt-get install -y ssh


1.配置系统工具
sudo add-apt-repository ppa:rock-core/qt4
sudo apt update
sudo apt-get install libcanberra-gtk-module
sudo dpkg -i synergy_1.8.8-stable+dfsg.1-1build1_amd64.deb
sudo apt install -f
geany ~/.config/Synergy/Synergy.conf   修改    edition=1

挂载分区
cd /
sudo mkdir /D
sudo blkid   记下UUID和tpye
sudo geany /etc/fstab
输入   UUID=A97208DF50FF5342   /D  ext4    defaults    0   0
重启
 
ntfs无法共享  在 sudo geany /etc/samba/smb.conf 添加 usershare owner only = no  重启smb sudo /etc/init.d/smbd restart

配置交换分区
1.sudo dd if=/dev/zero of=/swapfile bs=1M count=16000  ----  16G
2.sudo mkswap /swapfile
3.sudo swapon /swapfile
4.sudo vim /etc/fstab   写入 /swapfile    swap    swap    defaults    0    0    (不是空格,是table)
5.free -h   (查看交换分区信息)
删除交换分区
1.sudo swapoff /swapfile
2.sudo vim /etc/fstab      删除/swapfile这一行
3.rm -rf /swapfile
 
2.安装Android mtk编译环境
打开设置--关于--软件更新---下载自更改为  aliyun的源
sudo apt-get install curl
mkdir ~/bin
curl https://raw.githubusercontent.com/MoKee/git-repo/stable/repo > ~/bin/repo
chmod a+x ~/bin/repo
sudo geany /etc/apt/sources.list
最后一行填写

deb http://us.archive.ubuntu.com/ubuntu/ xenial main universe
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main universe

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo update-alternatives --config java
sudo update-alternatives --config javac
 
sudo apt-get install -y libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib flex bison gperf build-essential android-tools-adb
sudo apt-get install -y tofrodos python-markdown zlib1g-dev:i386 dpkg-dev libsdl1.2-dev libesd0-dev libncurses5-dev:i386 m4 android-tools-fastboot
sudo apt-get install -y libssl-doc git-core gnupg zip curl zlib1g-dev gcc-multilib libc6-dev-i386 libncurses5-dev libncurses5:i386 libstdc++6:i386
sudo apt-get install -y libxml2-utils xsltproc unzip lib32z1-dev ccache libssl-dev libswitch-perl x11proto-core-dev libx11-dev
sudo apt-get install -f
 
sudo ln -s /usr/lib/i386-linux-gnu/libncurses.so.6 /usr/lib/i386-linux-gnu/libncurses.so.5
sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
sudo ln -s /usr/lib/i386-linux-gnu/libtinfo.so.6 /usr/lib/i386-linux-gnu/libtinfo.so.5
sudo ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
mkdir ~/.android
echo 0x0e8d >> ~/.android/adb_usb.ini

附件70-android.rules    70-MTKinc.rules 在文末
sudo chmod 777 /etc/udev/rules.d/70-android.rules /etc/udev/rules.d/70-MTKinc.rules
sudo service udev restart
sudo chown root:root /usr/bin/fastboot
sudo chmod +s /usr/bin/fastboot
sudo cpan install XML::Simple

看下后面的踩坑,然后到这里编译就已经可以了,不过貌似8.1使用的openjdk是1.8.0_u222,   命令安装的是1.8.0_u292,命令安装的会报错,目前还没解决

[  0% 38/102944] Ensuring Jack server is installed and started
FAILED: setup-jack-server
/bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar  2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 4.11.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.32.CANDIDATE.jar 4.32.CANDIDATE || exit 47 )"
Jack server already installed in "/home/user/.jack-server"
Communication error with Jack server (35), try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'
SSL error when connecting to the Jack server. Try 'jack-diagnose'

如果你的代码是git管理的话继续
3.安装git
sudo apt-get install -y git gitk
git config --global user.name "xxx"
配置git使用附件bcompare gitconfig  ~/.gitconfig  配置了git lg  git diff tool

附件gitconfig 在文末
踩坑:
执行git pull时报错
Unable to negotiate with 113.89.244.20 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
fatal: Could not read from remote repository.
 
Please make sure you have the correct access rights
and the repository exists.
除了要加入底四步的id_rsa.pub,另外要在~/.ssh/新建文件config(如有,就添加以下字段)
Host *
KexAlgorithms +diffie-hellman-group1-sha1
 
生成id_rsa
ssh-keygen -t rsa -C "fae97"
ssh-add ~/.ssh/id_rsa
cat .ssh/id_rsa.pub  

4.安装ccache 并配置
sudo apt-get install ccache
 
which ccache
mkdir ~/.ccache
cd ~/.ccache/
ln -s /usr/bin/ccache gcc
ln -s /usr/bin/ccache g++
ln -s /usr/bin/ccache arm-linux-gcc
ln -s /usr/bin/ccache arm-linux-g++
 
export USE_CCACHE=1
export CCACHE_DIR=/home/user/.ccache
export PATH=/usr/lib/ccache:$PATH
export CCACHE_EXEC=/usr/bin/ccache
export CC="ccache gcc"
export CXX="ccache g++"
 
配置终端标题
加入~/.bashrc
function git_branch {
branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
if [ "${branch}" != "" ];then
if [ "${branch}" = "(no branch)" ];then
branch="(`git rev-parse --short HEAD`...)"
fi
echo " ($branch)"
fi
}
export PS1='\u@\h \[\033[01;36m\]\w\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ '
 
 
踩坑:
1. FAILED: /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_l.cpp system/tools/aidl/aidl_language_l.ll"
  在build/envsetup.sh脚本中最后添加一句话 :  export LC_ALL=C
   
2. FAILED: /bin/bash -c "prebuilts/misc/linux-x86/bison/bison -d  --defines=out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.h -o out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_y.cpp  
  sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
   
3. FAILED: /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_l.cpp system/tools/aidl/aidl_language_l.ll"
  sudo apt-get install m4
   
4. Communication error with Jack server (52). Try 'jack-diagnose'
  out/host/linux-x86/bin/jack-admin kill-server  
  out/host/linux-x86/bin/jack-admin start-server
  这里需要注意的是,当执行kill-server时,查看jack服务器是否已经成功停止。启动时,查看启动是否成功。
  如果启动成功,可继续编译。通常如果机器配置不够,再次执行会报问题e错误。
   
5. Out of memory error (version 1.2-rc4 'Carnac' (298900 f95d7bdecfceb327f9d201a1348397ed8a843843 by  
   android-jack-team@google.com)).GC overhead limit exceeded.
   
  这也是Jack服务器编译过程中会报的错,修改启动参数即可。打开文件prebuilts/sdk/tools/jack-admin
  写入: JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -Xmx4096m -cp $LAUNCHER_JAR $LAUNCHER_NAME"
  搜索JACK_SERVER_COMMAND关键字符串,在-cp参数前添加-Xmx4096m即可。此时再按照d问题解决方案,首先kill-server,
  然后重新启动start-server,并查看启动返回日志中的参数是否有我们修改后的-Xm4096m。我在修改配置文件过程中,
  重启后参数未生效,最后执行了make clobber命令然后重新编译生效。
 
6. No command 'adb' found, did you mean:
  没有安装adb,执行以下命令安装即可:sudo apt-get install android-tools-adb
   
7. adb devices : no permissions(udev)或是fastboot devices:no permissions(udev)
  mtk flash tool无法下载
  手机联上电脑后,在终端输入 lsusb
  Bus 003 Device 008: ID 0e8d:201c MediaTek Inc.
   
  在终端中执行下面命令
  echo 0x0e8d >> ~/.android/adb_usb.ini
   
  终端中执行 sudo chmod 777 /etc/udev/rules.d/70-android.rules /etc/udev/rules.d/70-MTKinc.rules
 
  sudo service udev restart
  最后重新插拔usb生效
 
8. fastboot < waiting for device >
  查看命令fastboot devices,这里没有udev错误,若有参考上一问题g解决方案。若结果显示no permission,使用which命令查看fastboot路径
  which fastboot     通常这里的路径为源码编译目录新生成的文件。此时有两种解决方案:
  1.使用sudo apt-get install android-tools-fastboot 命令安装fastboot工具,然后使用sudo 执行fastboot devices即可。
  2.进入which查看fastboot路径目录,执行以下命令:
  sudo chown root:root fastboot
  sudo chmod +s fastboot
  此时再运行fastboot device命令成功。
   
9.modem编译报错
  Can't locate XML/Simple.pm in @INC (@INC contains: /opt/local/lib
  sudo cpan install XML::Simple
   
  Can't locate File/Copy/Recursive.pm in @INC (
  perl -MCPAN -e install "install File::Copy::Recursive"
  不成功,就执行
  sudo cpan install File::Copy::Recursive

10.

报错Can’t locate Switch.pm in @INC

  1. $ cpan
  2. cpan[1]> install Switch 输入cpan后会进入输入命令行,直接敲install Switch即可
  3. cpan[2]> exit 输入exit退出即可
  4. sudo apt-get install libswitch-perl
  5. sudo apt-get  install libxml2-utils

文章引用了论坛大神的资料,只是出处我没保存,就没在文章体现,如果大神介意,请联系我,我加上引用出处

链接:https://pan.baidu.com/s/1Yr3FDTjdYNGRxTKPVyfKEg  
提取码:ipdi

20210915补充:

ubuntu共享了某个文件夹,然后windows复制文件进去后是上锁状态,解决:

sudo vi /etc/samba/smb.conf

在 [global] 放入以下内容
force user = 帐号
force group = 群组
create mask = 0664
directory mask = 0775

存档,重启smbd
sudo service smbd restart

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值