Current location - Quotes Website - Signature design - How to use the local package of android gradle
How to use the local package of android gradle
The Android development of Qianfeng Dingding College answers for you:

-

Gradle 2.2. 1

-

Construction time: 2014-1-24 09: 45: 35 UTC.

BuildNo.: None

Version: 6fcb59c06f43a4E6b1bcb401f7686a8601a1fb4a.

Groovy: 2.3.6

Ant: Apache Ant(TM) version 1.9.3 compiled in1February 23rd 2013 JVM:1.7.0 _ 60 (Oracle Corporation 24.60-B09) OS:

Mac OS X 10.9.5 x86_64

2. Then execute. /gradlew clean

Executing this command will download some dependencies of Gradle. After successful download and compilation, you will see the following information:

: Application: Clear Latest

: extras:ShimmerAndroid: Clearing the latest version succeeded.

3. Final implementation. /gradlew version

This command will directly compile and generate the corresponding apk file. If you see the following, the construction is successful.

Build successfully

Total time: 3 1.456 seconds

Next, in the 9GAG/app/build/outputs/apk directory, you will see something similar to app-debug-unattended. Apk, application-published-unsigned. Apk and so on. You should be able to understand the meaning by looking at the name. Unaligned stands for zip optimization and unsigned stands for unsigned. Then you can directly install apk to see the running effect.

The above is my personal habit of reading third-party source code. You should not understand some of the gradle commands mentioned above, and I will explain them one by one later.

Import Android Studio

However, if you still want to import Android Studio, then briefly introduce the method and some precautions of importing Studio.

1, select file->; Import the project and select the directory of the local 9GAG project.

2. I will still download Gradle as soon as possible. In fact, I have downloaded it from the command line, but I still have to download it again this time (still over the wall). It may be a bug, and the next version may be fixed.

3. After importing, you need to pay attention to the following points.

For the buildToolsVersion under build.gradle under each module, that is, 9GAG/app/build.gradle and 9gag/extras/Shimmer Android/build.gradle, you can open the SDK Manager to view the locally installed SDK Build-tools, as shown in the following figure. If the corresponding version is not installed, please download it first.

The version of gradle plug-in under build.gradle in the project root directory, such as the content of 9GAG/build.gradle:

Classpath' com.android.tools.build: gradle:1.0.0'

Android Studio 1.0 must specify the version of gradle plug-in 1.0.

The version of Gradle Wrapper contains the following contents in the 9gag/gradle/wrapper/gralde-wrapper.properties file:

# Thursday1February18th 16: 02: 24 CST 20 14

distribution base = GRADLE _ USER _ HOME

DistributionPath = packaging/distribution

zipStoreBase=GRADLE_USER_HOME

zipStorePath=wrapper/dists

distribution URL = https \://services . gradle . org/distributions/gradle-2 . 2 . 1-all . zip

The above content specifies that the version of gradle is 2.2. 1. If you manually change the version of the gradle plug-in in Studio, you will be prompted whether to update the version of Gradle Wrapper.

If the above places confirm that the version is ok, then there should be no problem importing Android Studio. Some old projects may have old versions of gradle and still use some old syntax. If the compilation fails, please refer to the fourth tutorial series of Android Studio-Gradle Foundation to change to the latest grammar.

Gradle common commands

You have been exposed to some of the above orders, such as. /gradlew-v./gradlew clean/gradlew build。 Please pay attention. /gradlew,。 /stands for the current directory, and gradlew stands for gradle wrapper, which means a layer of packaging for gradle. You can understand that gradle is packaged locally in this project. That is, gradle wrapper, and the directory and version it points to are declared in the 9gag/gradle/wrapper/gralde-wrapper.properties file. As long as the download is successful, the global gradle command can be replaced by the grdlew wrapper command.

Understand the concept of gradle wrapper, and the following common commands are easy to understand.

. /gradlew -v version number

. /gradlew clean clears the build folder in the 9GAG/app directory.

. /gradlew build checks dependencies and compiles and packages them.

Please pay attention. The /gradlew build command outputs all packages in the debugging and publishing environment. What if the package that only needs to be released is officially released? Here is a very useful command * * assemble * *, such as

. /gradlewassembedbdebug compile and debug the package.

. /grad Lew assembler please compile and distribute the package.

In addition, assemble can also be used in combination with productFlavors, which will be further explained in the following multi-channel packaging.

. /gradlew installs the release mode package and installs it.

. /gradlew uninstallRelease uninstalls the release mode package.

The next article will introduce the convenient multi-channel packaging using Gradle and the complete Gradle configuration in the project.