Method of Andriod studio Packaging aar

  • 2021-10-25 07:45:29
  • OfStack

Because of different projects, some public libraries are c + +, and some with resources. Simple replication is a round of configuration when encountering library upgrade, and compiling into aar solves these troubles.

However, by default, make moudle of andriod studio only generates debug packets, apk of release is generated in time above 3.0, and aar of release will not be generated.

At this time, use the command "gradlew assembleRelease", open the terminal in Andriod studio, and execute it in the root directory of the project (it can't be executed in Moudle).

If the problem of Unsupported major. minor version 52.0 occurs, it is that the version of your terminal is wrong, at least 8.0, so why can Andriod studio be generated normally, but not at the command line, because Andriod studio has a built-in java version.

How to solve this problem, many people choose to upgrade the java version, but there is a simpler way. If some people need a lower version of java to test and support the lower version of java program, do they still upgrade?

Because it is compiled with gradle, open the batch file of gradle to see what the solution is.

Generally speaking, gradle. bat under C:\ Program Files\ Android Studio\ gradle\ gradle-4. 1\ bin has different version numbers, and the actual directory can be checked in settings of Andriod studio.

In the batch file, we see important statements:

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

Take the variable JAVA_HOME, which is easy to do. You only need to execute set JAVA_HOME=C at the bottom of the command line:\ Program Files\ Android\ Android Studio\ jre. This command is only valid for the current command session, and will not change the global java version. After execution, you can execute gradlew assembleRelease.

Where is the java version path built in Andriod studio? Check it in settings of Andriod studio.

Summarize


Related articles: