Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Ubuntu environment

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article will give you a detailed explanation on how to build a Ubuntu environment. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Android officially recommends using Ubuntu to compile the source code of the Android system. Ubuntu is one of the most popular linux systems with easy to use and friendly interface. The linux system used in building linux platform analysis environment and Android source code compilation environment is 64-bit Ubuntu, version number is 18.04.

1.2.1 install JDK

There are two options for installing JDK on Ubuntu, one is to use JDK officially provided by Oracle, and the other is to use a third-party open source OpenJDK. Using these two versions of JDK, you can normally develop Android software and compile Android source code in a production environment. Let's first introduce the use of Oracle's official JDK, which can be done by following these steps. Visit the Oracle official website and download the JDK installation package at http://www.oracle.com/technetwork/java/javase/downloads/index.html. Install the JDK1.8.0_241 version here. Create the following directories

Sudo mkdir-p usr/local/java

Place the locally downloaded jdk package in the / usr/local/java directory and upload the installation package using the finashell tool (note that you need to switch to the root user and give the java file 777 permissions). Unpack the package and execute the command

Sudo tar xvzf jdk-8u241-linux-x64.tar.gz

Open the / etc/profile file to configure environment variables

Sudo vi / etc/profile

Add the following configuration to the / etc/profile file

JAVA_HOME=/usr/local/java/jdk1.8.0_241

JRE_HOME=/usr/local/java/jdk1.8.0_241

PATH=$PATH:$JRE_HOME/bin:$JAVA_HOME/bin

Export JAVA_HOME

Export JRE_HOME

Export PATH

Update alternatives

Sudo update-alternatives-install "/ usr/bin/java"java" / usr/local/java/jdk1.8.0_241/bin/java "1

Sudo update-alternatives-install "/ usr/bin/javac"javac" / usr/local/java/jdk1.8.0_241/bin/javac "1

Sudo update-alternatives-install "/ usr/bin/javaws"javaws" / usr/local/java/jdk1.8.0_241/bin/javaws "1

Sudo update-alternatives-set java/ usr/local/java/jdk1.8.0_241/bin/java

Sudo update-alternatives-set javac / usr/local/java/jdk1.8.0_241/bin/javac

Sudo update-alternatives-set javaws / usr/local/java/jdk1.7.0_80/bin/javaws

Reload profile

Source / etc/profile

Verify jdk installation

Java-version

If the installation is successful, execute the java-version command to see the output

Root@ubuntu:/# java-version

Java version "1.8.0mm 241" Java (TM) SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot (TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

Another way to install Oracle JDK is by adding a PPA command line. Update the package list

Sudo apt update

Install a specific version of jdk, where jdk1.8 is installed

Sudo apt install openjdk-8-jdk

Verify installation

Java-version

The following message indicates that the installation was successful

Root@ubuntu:/# java-version openjdk version "1.8.0mm 242"

OpenJDK Runtime Environment (build 1.8.0mm 242-8u242-b08-0ubuntu3~18.04-b08)

OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

Multiple versions of JDK can be installed and retained at the same time in ubuntu, and can be switched between different versions as needed. You can switch java to a different version by executing the following command.

Sudo update-alternative-config java

Execute the following command to switch javac to a different version of OpenJDK.

Sudo update-alternatives-config javac

After you have done this, execute java-version to see if the JDK version has been switched successfully.

1.2.2 install Android SDK

When installing Android SDK on ubuntu, there are also two ways to download the Android SDK package and to update it through the command line and to install it using Android Studio's built-in SDK management interface. The installation steps for both methods are similar to those in Windows, so I won't repeat them here.

1.2.3 install Android NDK

When installing Android NDK in ubuntu, there are also three ways to download the Android NDK package and update it through the command line, download the Android NDK package and decompress it, and install it using Android Studio's built-in NDK management interface. The installation steps of these three methods are similar to those in Windows, so I won't repeat them here.

1.2.4 Android Studio integrated development environment

Android Studio in ubuntu is provided as a zip package and can be downloaded from https://developer.android.google.cn/studio/#downloads. Create the following directories

Sudo mkdir-p usr/local/AndroidStudio

Place the locally downloaded AndroidStudio package in the / usr/local/AndroidStudio directory (note that you need to switch to the root user and give permission to the AndroidStudio file 777)

Extract this compressed package.

Sudo tar xvzf android-studio-ide-192.6200805-linux.tar.gz

Set up the AndroidStudio cache directory, go to the AndroidStudio software root directory / bin directory, there is an idea.properties file in this directory, open this file.

Sudo vi idea.properties

Open the four comments in the figure and set them to your own directory.

Start AndroidStudio, open the command line in the bin directory of the software, and execute the command as follows:

Bash studio.sh

After executing this command, you can enter the configuration interface of AndroidStudio. Click the "Configure"-"Create Desktop Entry" option to create a desktop icon for Android Studio, as shown in the following figure:

After you create the icon, you can see the icon of Android Studio in the left bar of the system.

This is the end of the article on "how to build a Ubuntu environment". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report