create apk file from command prompt

2020-06-22 17:41发布

i want to create .apk file from command prompt. for this i follow this link

and try to complete it with ant..but it is giving me error.

taskdef class com.android.ant.setuptask cannot be found

can any one please help me what mistake i am doing or provide me a step by step tutorial for this.

thanks in advance...

标签: android
1条回答
够拽才男人
2楼-- · 2020-06-22 18:24

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

You'll also need to specify one of the seven or so Android build targets because the default build target is 'help'.

If you just run ant -Dsdk.dir=<path to Android SDK>, you'll get some help output, like so:

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's .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 the APK, you have to specify debug or release.

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

查看更多
登录 后发表回答