首页 > 系统 > Android > 正文

Ubuntu配置多版本JDK编译Android源码

2019-11-09 17:19:55
字体:
来源:转载
供稿:网友
Android6.0使用的是JDK7进行编译,但是更新Android7.0以后,使用的是JDK8进行编译。因此需要进行来回切换。

针对Ubuntu 14.04

因为OpenJDK8不支持14.04的源,因此需要手动安装OpenJDK8

google官方配置开发环境链接 https://source.android.com/source/initializing.html

步骤:

Download the .deb packages for 64-bit architecture from archive.ubuntu.com:

openjdk-8-jre-headless_8u45-b14-1_amd64.deb with SHA256 0f5aba8db39088283b51e00054813063173a4d8809f70033976f83e214ab56c0openjdk-8-jre_8u45-b14-1_amd64.deb with SHA256 9ef76c4562d39432b69baf6c18f199707c5c56a5b4566847df908b7d74e15849openjdk-8-jdk_8u45-b14-1_amd64.deb with SHA256 6e47215cf6205aa829e6a0a64985075bd29d1f428a4006a80c9db371c2fc3c4c

Optionally, confirm the checksums of the downloaded files against the SHA256 string listed with each package above.

For example, with the sha256sum tool:

sha256sum {downloaded.deb file}

Install the packages:

update

sudo apt-get update

Run dpkg for each of the .deb files you downloaded. It may PRoduce errors due to missing dependencies:

sudo dpkg -i {downloaded.deb file}

To fix missing dependencies:

sudo apt-get -f install

更新默认java版本:

sudo update-alternatives --config javasudo update-alternatives --config javac选择你要变更的JDK的版本就行。当然我们一般都在.zshrc中定义环境变量,因此只要改变zshrc中的环境变量就能达到jdk版本的变换,其实上述操作可以省略。针对Ubuntu 16.04 至于16.04,由于已经拥有OpenJDK8的源,直接安装就可以了,同时向下也兼容OpenJDK7,所以两个都进行安装后。在.zshrc或者.bashrc中配置环境变量属性就能进行切换了。由于这个步骤较为简单,就不赘述了。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表