How to compile ss for android on Ubuntu 18.04.2 LTS.

注:纯手工原创文章,转载请说明出处。英文水平有限,如有不对之处,烦劳指出,不甚感激。

一、Introduction
In this article, I assume you have learned both How to create a regular app and How to install Ubuntu system(Arbitrary version but it’s better to know about 18.04.2 LTS as this post base on it).

二、Prerequisites.
1、 Android Studio runs on Ubuntu system with at least 30GB spaces of hard disks.
2、JDK 1.8+.
3、Git.

As I metioned above, To install ubuntu is a necessary skill So that I won’t show you how to install here. Because there are many articles will point out a wrong way to you to set jdk 1.8 into system environment(This is very important as an incorrect setting will lead errors when you compile the shadowsocks project on Android Studio), But don’t worry I will walk you through how to correctly set environment for JDK. Additionally, Git is easily to be installed on Ubuntu so that I won’t teach you here too, if you have any problem with it, Just leave a comment. and you don’t need to learn NDK but just download it automatically by Android Studio.

三、Install JDK 1.8+ and Set environment for it. (Ignore this step if you alread know )

1、Open the following website and do as the pic shows, I will illustrate you.
Click here to download JDK 1.8+

在这里插入图片描述
2、After downloaded it, Open the terminal on the folder where the jdk-8u201-linux-x64.tar.gz contained.
3、Switch your role to root.(if you don’t know how to switch to root role, google or baidu it).
4、Create a folder for jdk. typing the following code on terminal to make a folder.(Make sure now you’re root role)

mkdir /usr/local/java

5、Extract jdk-8u201-linux-x64.tar.gz to /usr/local/java . Just code as the following commands.

tar -zxvf jdk-8u201-linux-x64.tar.gz -C /user/coal/java

6、For now, You have installed JDK1.8+ into your system. but you have to set environment for it to make sure you can run jdk everywhere you need.

7、Open the /etc/environment file by following code(vi can do same thing but it’s a bit difficult to learners on Linux):

gedit /etc/environment

1、JAVA_HOME.
2、CLASSPATH.
3、PATH.
The following code is mine. You should change it according to your jdk version and jdk folder name.

JAVA_HOME=/usr/local/java/jdk1.8.0_201
CLASSPATH=.:${JAVA_HOME}/lib
PATH="/usr/local/java/jdk1.8.0_201/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

I have makred parts you have to change in the pic. Please, write these code carefully. If you don’t, You won’t compile this project successfully.

8、Save and then close it. and then, update it by following code:

source /etc/environment

9、Now, you have set JDK environment. To verify your setting whether it’s correct. Do two steps:
First Step.
1、echo $JAVA_HOME
2、echo $CLASSPATH
3、echo $PATH

Make sure these constants will print right things on your Terminal, Just like my pic shows:
在这里插入图片描述
Second Step.
1、Relogin your root account.
在这里插入图片描述
2、Check your JDK environment whether it’s right on.
Just code:

java -version

在这里插入图片描述
If your terminal prints as my pic shows. Congratulations! You’re now successfully setting JDK Environment on your ubuntu system.

四、Pull shadowsocks from github and compile it.

The newest version of shadowsocks is easier compiled than ever. You just need to import it from github into Android Studio as a regular android project.

When it’s sync failed and shows the error message as the pic. Just click the Install NDK Text(blue color) below.
在这里插入图片描述
Now, It’s doing the last step to install NDK tool.
在这里插入图片描述
After that, You can run it on your handsets.
在这里插入图片描述

Finally, if you have any problem with it, just leave a comment. Thank you for your reading.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值