Build the Android environment on the Ubuntu system and download apk from Google Play

Source: Internet
Author: User
Tags versions zip git clone

Build a fully command-line Android build system

Step 1 Installing JDK environment

With the Android JDK it's best to use the official JDK version instead of the open JDK, and here's how to install JDK 1.7 under Unbuntu.

The code is as follows:

sudo add-apt-repository Ppa:webupd8team/java

sudo apt-get update

sudo apt-get install Oracle-java7-installer

Step 2 Installs the Android SDK

Some of the command-line tools for the Android SDK Toolkit are based on 32-bit systems, and the 64 running 32 programs for the platform must install some of the i386 's dependent libraries, as follows:

The code is as follows:

sudo dpkg--add-architecture i386

sudo apt-get update

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1

After installing the 32-bit dependency library, we use wget to officially download the latest Linux Android SDK pack.

The code is as follows:

CD ~

wget http://dl.google.com/android/android-sdk_r24.0.1-linux.tgz

Tar xvzf android-sdk_r24.0.1-linux.tgz

Edit. Profile or. Bash_profile adds the following directory to the path search path, ensuring that some of the Android SDK's command tools are available directly to the terminal, such as the ADB command.

The code is as follows:

Android_home= $HOME/android-sdk-linux

Export path= "$PATH: $ANDROID _home/tools: $ANDROID _home/platform-tools"

Exprot Android_home

Make environment variables effective

The code is as follows:

SOURCE ~/.profile

After the environment variable is in effect, you can use the Android command to list the SDK-related listings so that we choose the SDK version that matches our own project. (Just installed the most basic SDK, to fully meet your development environment need to choose from the following list of the SDK and tools you need to update the download)

The code is as follows:

Android List SDK--all

The output looks like this:

1-android SDK Tools, revision 24.0.1

2-android SDK Platform-tools, revision 21

3-android SDK Build-tools, revision 21.1.2

4-android SDK Build-tools, revision 21.1.1

5-android SDK Build-tools, revision 21.1

6-android SDK Build-tools, revision 21.0.2

7-android SDK Build-tools, revision 21.0.1

8-android SDK Build-tools, revision 21

9-android SDK Build-tools, revision 20

10-android SDK Build-tools, Revision 19.1

11-android SDK Build-tools, revision 19.0.3

12-android SDK Build-tools, revision 19.0.2

13-android SDK Build-tools, revision 19.0.1

14-android SDK Build-tools, revision 19

15-android SDK Build-tools, revision 18.1.1

16-android SDK Build-tools, revision 18.1

17-android SDK Build-tools, revision 18.0.1

18-android SDK Build-tools, revision 17

19-documentation for Android SDK, API, Revision 1

20-SDK Platform Android 5.0.1, API, Revision 2

21-SDK Platform Android 4.4w.2, API, Revision 2

22-SDK Platform Android 4.4.2, API, Revision 4

23-SDK Platform Android 4.3.1, API, Revision 3

24-SDK Platform Android 4.2.2, API, Revision 3

....

Here are the different versions of the Android API and the different build tools, select the serial number of the project you want to install, and here I want to install build tools 19.1, building tools 21 and Android 4.2 2 SDK so select serial number "1,2,3,20,2 1,22,23 "

The code is as follows:

Android Update Sdk-u-a-t 1,2,3,10,20,21,22,23

Step 3 Install Gradle build environment

Using Ant to build a project is already a past, and here we choose a more powerful and convenient build tool gradle.

Download Grdle binary Package

The code is as follows:

CD ~

wget Https://services.gradle.org/distributions/gradle-2.2.1-bin.zip

Release to the local home directory, create a symbolic link named "Gradle", the advantage of symbolic connection is to facilitate version update, with a new version directly modify the symbolic link.

The code is as follows:

Unzip Gradle-2.2.1-bin.zip

Ln-s gradle-2.2.1 Gradle

Configure and make the GRADLE environment variable effective, edit the ~/.profje file to add the following

The code is as follows:

Gradle_home= $HOME/gradle

Export path= $PATH: $GRADLE _home/bin

Save the environment variable to take effect after saving

The code is as follows:

SOURCE ~/.profile

After the environment variable is in effect you can enter the ' gradle ' command at the terminal and run it to detect if the Gradle is installed successfully.

The code is as follows:

Gradle

If there is no problem with the installation configuration, you will be prompted with information similar to the following

The code is as follows:

: Help

Welcome to Gradle 2.2.1

To run a build, run Gradle ...

To a list of available tasks, run Gradle tasks

To a list of command-line options, run Gradle--help

Build successful

Verify that the Android application can be compiled

Complete the above environment configuration, one of our Android infrastructure environment is fully configured, the next thing to do is to try to use Gradle to compile an Android application to verify that my build environment is OK, download my write a Gadle demo example to test.

The code is as follows:

git clone Https://github.com/examplecode/gradle_demo

CD Gradle_demo/hello-apk-with-gradle

Gradle Build

How to download apk files from Google Play store on Linux

Python Requirements

Googleplaydownloader needs to support SSL/TLS communications using Python with SNI (server name indication), which is introduced by Python 2.7.9 or later. This allows some old distributions such as Debian 7 wheezy and earlier versions, Ubuntu 14.04 and earlier versions or Centos/rhel 7 and earlier versions to meet this requirement. Let's say you already have a release version with Python 2.7.9 or later, and you can install googleplaydownloader like this.

Install Googleplaydownloader on Ubuntu

On Ubuntu, you can use the officially built Deb package. One condition is that you may need to manually install a required dependency.

On the Ubuntu 14.10

Download the Python-ndg-httpsclient deb package, which is a missing dependency in an older Ubuntu release. Also download Googleplaydownloader's official Deb package.

The code is as follows:

$ wget Http://mirrors.kernel.org/ubuntu/pool/main/n/ndg-httpsclient/python-ndg-httpsclient_0.3.2-1ubuntu4_all.deb

$ wget Http://codingteam.net/project/googleplaydownloader/download/file/googleplaydownloader_1.7-1_all.deb

As shown below, we will use the Gdebi command to install the two Deb files. The GEDBI command will automatically handle any other dependencies.

The code is as follows:

$ sudo apt-get install Gdebi-core

$ sudo gdebi python-ndg-httpsclient_0.3.2-1ubuntu4_all.deb

$ sudo gdebi googleplaydownloader_1.7-1_all.deb

On the Ubuntu 15.04 or newer version

The recent Ubuntu release has all the required dependencies, so the installation process can be done directly as follows.

The code is as follows:

$ wget Http://codingteam.net/project/googleplaydownloader/download/file/googleplaydownloader_1.7-1_all.deb

$ sudo apt-get install Gdebi-core

$ sudo gdebi googleplaydownloader_1.7-1_all.deb

Install Googleplaydownloader on Debian

Due to its python requirements, Googleplaydownloader cannot be installed on a Debian 7 wheezy or earlier version unless you upgrade the Python version it has owned.

In the Debian 8 Jessie and later versions:

The code is as follows:

$ wget Http://codingteam.net/project/googleplaydownloader/download/file/googleplaydownloader_1.7-1_all.deb

$ sudo apt-get install Gdebi-core

$ sudo gdebi googleplaydownloader_1.7-1_all.deb

Install Googleplaydownloader on Fedora

Since Googleplaydownloader was originally developed for a Debian-based release, if you want to use it on Fedora, you need to start installing it from its source code.

First install the required dependencies.

The code is as follows:

$ sudo yum install python-pyasn1 WxPython python-ndg_httpsclient Protobuf-python

Then install it as follows.

The code is as follows:

$ wget http://codingteam.net/project/googleplaydownloader/download/file/googleplaydownloader_1.7.orig.tar.gz

$ TAR-XVF googleplaydownloader_1.7.orig.tar.gz

$ CD googleplaydownloader-1.7

$ chmod o+r-r.

$ sudo python setup.py install

$ sudo sh-c "echo" python/usr/lib/python2.7/site-packages/googleplaydownloader-1.7-py2.7.egg/googleplaydownloader/ googleplaydownloader.py ' >/usr/bin/googleplaydownloader '

Download APK files from Google Play Store using Googleplaydownloader

Once you've installed your googleplaydownloader, you can download APK files from the Google Play Store as follows. (LCTT: Obviously you need to get your Linux to climb the ladder)

First, start the application by entering the following command:

The code is as follows:

$ googleplaydownloader

In the Search field, enter the name of the application you want to download from the Google Play store.

Once you have found the application from the search list, select the application, and then click the "Download selected APK file" button. Finally, you will find the downloaded APK file in your home directory. Now you can move the downloaded APK file to your selected Android device and install it manually.

I hope this tutorial will be of some help to you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.