Create apk file from command line

I want to create a .apk file from the command line. for this i follow this link

and try to execute it with ant .. but it gives me an error.

class taskdef com.android.ant.setuptask could not be found

Can someone help me what mistake I am making or provide me with a step by step guide for this.

thanks in advance...

+4
source share
1 answer

You need to pass sdk.dir to ant, i.e. ant -Dsdk.dir=<path to Android SDK>

You also need to specify one of the seven target build goals for Android, because the default build goal is "help."

If you just run ant -Dsdk.dir=<path to Android SDK> , you will get some help, for example:

 help: [echo] Android Ant Build. Available targets: [echo] help: Displays this help. [echo] clean: Removes output files created by other targets. [echo] compile: Compiles project .java files into .class files. [echo] debug: Builds the application and signs it with a debug key. [echo] release: Builds the application. The generated apk file must be [echo] signed before it is published. [echo] install: Installs/reinstalls the debug package onto a running [echo] emulator or device. [echo] If the application was previously installed, the [echo] signatures must match. [echo] uninstall: Uninstalls the application from a running emulator or [echo] device. BUILD SUCCESSFUL Total time: 7 seconds 

To build an APK, you must specify debug or release .

ant -Dsdk.dir=<path to Android SDK> debug

+7
source

Source: https://habr.com/ru/post/1342764/


All Articles