Gradle-2.2.1Next, we will introduce how to install and configure a compilation and building system under the command line.
Step 1 install the JDK EnvironmentIt is best to use JDK official version instead of Open JDK for JDK with android. The following is how to install JDK 1.7 under unbuntu.
sudo add-apt-repository ppa:webupd8team/javasudo apt-get updatesudo apt-get install oracle-java7-installer
Step 2 install the Android SDKSome command line tools of the android sdk kit are based on 32-bit systems. To run 32 programs on a 64-bit platform, you must install some i386 dependent libraries. The method is as follows:
sudo dpkg --add-architecture i386sudo apt-get updatesudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1
After the 32-bit dependent library is installed, we use wget to download the latest android SDK package for linux.
cd ~wget http://dl.google.com/android/android-sdk_r24.0.1-linux.tgztar xvzf android-sdk_r24.0.1-linux.tgz
Edit. profile or. bash_profile to add the directory below to the path search path. Make sure that some android SDK command tools can be directly used on the terminal, such as the adb command.
ANDROID_HOME=$HOME/android-sdk-linuxexport PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-toolsexprot ANDROID_HOME
Make environment variables take effect
source ~/.profile
After the environment variables take effect, you can use the android command to list sdk-related lists so that we can select the SDK version that matches our project. (The most basic SDK has just been installed. To fully meet your development environment needs, You must select the SDK and tool update and download from the list below)
android list sdk --all
The output is as follows:
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 21, revision 1 20- SDK Platform Android 5.0.1, API 21, revision 2 21- SDK Platform Android 4.4W.2, API 20, revision 2 22- SDK Platform Android 4.4.2, API 19, revision 4 23- SDK Platform Android 4.3.1, API 18, revision 3 24- SDK Platform Android 4.2.2, API 17, revision 3 ....
Different Android API versions and build tools are included. Select the serial number of the project you want to install. Here I want to install build tools 19.1, for SDK build tools 21 and android 4.2.2 and above, select the serial number ", 23"
android update sdk -u -a -t 1,2,3,10,20,21,22,23
Step 3 install the gradle Build EnvironmentUsing Ant to build a project is already in the past. Here we use gradle, a more powerful and convenient building tool.
Download the grdle Binary Package
cd ~wget https://services.gradle.org/distributions/gradle-2.2.1-bin.zip
Release it to the local Home directory and create a symbolic link named "gradle". The advantage of symbolic connection is that it facilitates version updates. With a new version, you can directly modify the symbolic link.
unzip gradle-2.2.1-bin.zip ln -s gradle-2.2.1 gradle
Configure the gradle environment variable and make it take effect. Edit ~ /Add the following content to the profje file.
GRADLE_HOME=$HOME/gradleexport PATH=$PATH:$GRADLE_HOME/bin
Save and make the environment variable take effect
source ~/.profile
After the environment variables take effect, you can enter the 'gradle' command on the terminal and run it to check whether gradle is successfully installed.
gradle
If the installation configuration is correct, a message similar to the following is displayed.
:helpWelcome to Gradle 2.2.1To run a build, run gradle
...To see a list of available tasks, run gradle tasksTo see a list of command-line options, run gradle --helpBUILD SUCCESSFUL
Verify that the android Application can be compiledAfter completing the above environment configuration, all the basic build environments under one of our Android systems have been configured, the next thing to do is to use gradle to compile an android app to verify that my compiling environment is OK. Download a gadle demo example I wrote for testing.
git clone https://github.com/examplecode/gradle_democd gradle_demo/hello-apk-with-gradlegradle build
After compilation, you will find the compiled apk package in the "hello-apk-with-gradle/build/outputs/apk" directory. As for how to integrate it into your own project, you just need to provide a "gradle. build" script for your project following the example.