我想使用Windows命令行安装一个文件。首先,我想在编译完所有.jar文件后为Android应用程序创建一个.apk文件,而不使用Eclipse。

有人知道如何在不使用Eclipse的情况下,仅通过使用命令行就可以做到这一点吗?


当前回答

使用Android调试桥命令行工具adb eg: adb install filename.apk。

这里有一个很好的adb参考资料

install [options] <PATH>    Installs a package (specified by <PATH>) to the system.
Options:

-l: Install the package with forward lock.
-r: Reinstall an exisiting app, keeping its data.
-t: Allow test APKs to be installed.
-i <INSTALLER_PACKAGE_NAME>: Specify the installer package name.
-s: Install package on the shared mass storage (such as sdcard).
-f: Install package on the internal system memory.
-d: Allow version code downgrade.
uninstall [options] <PACKAGE>   Removes a package from the system.
Options:

-k: Keep the data and cache directories around after package removal.

其他回答

您可以使用下面的代码从命令行安装应用程序

adb install example.apk

这个apk安装在当前打开的模拟器的内存中。

adb install -s example.apk

这个apk安装在当前打开的模拟器的sd卡中。

您还可以将apk安装到adb连接设备列表中的特定设备。

adb -s emulator-5554 install myapp.apk

有关其他选项,请参阅adb帮助。

您可以通过在关键字'install'之前输入设备/模拟器标识符,然后输入apk的路径,将apk安装到特定的设备/模拟器。注意,'install'关键字后面的-s开关(如果有的话)表示安装到sd卡。例子:

adb -s emulator-5554 install myapp.apk

要安装调试(测试)apk,使用-t:

运行Build-Make项目

在app文件夹中查找最后生成的apk。

例子:

adb  install -t C:\code\BackupRestore\app\build\outputs\apk\debug\app-debug.apk

使用Android调试桥命令行工具adb eg: adb install filename.apk。

这里有一个很好的adb参考资料

install [options] <PATH>    Installs a package (specified by <PATH>) to the system.
Options:

-l: Install the package with forward lock.
-r: Reinstall an exisiting app, keeping its data.
-t: Allow test APKs to be installed.
-i <INSTALLER_PACKAGE_NAME>: Specify the installer package name.
-s: Install package on the shared mass storage (such as sdcard).
-f: Install package on the internal system memory.
-d: Allow version code downgrade.
uninstall [options] <PACKAGE>   Removes a package from the system.
Options:

-k: Keep the data and cache directories around after package removal.

按Win+R > cmd 导航到android-sdk windows文件夹中的platform-tools\ 亚洲开发银行类型 现在按照Mohit Kanada所写的步骤(确保你提到了。apk文件的整个路径,例如。d: \ android应用程序\ test.apk)