我想使用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.

其他回答

这太简单了!

例如,我的apk文件位置是:d:\myapp.apk

运行cmd 导航到“platform-tools”文件夹(在SDK文件夹中) 启动模拟器设备(假设它的名字是5556:MyDevice) 在cmd中输入以下代码: Adb -s emultor -5556 install d:\myapp.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.

命令安装APK文件,就像它在Android工作室,你可以看到下面。

1)推广应用:

adb push /pathOfApk/com.my.awesome.apk /data/local/tmp/com.my.awesome

com.my.awesome是你的包裹。

2)安装:

adb shell pm install -t -r "/data/local/tmp/com.my.awesome"

您可以通过使用adb命令行工具或gradle命令来做到这一点: 请看本指南。

设置命令行adb

export PATH=/Users/mayurik/Library/Android/sdk/platform-tools/adb:/Users/mayurik/Library/Android/sdk/tool

Gradle命令来构建和安装。

 #Start Build Process
    echo "\n\n\nStarting"
    ./gradlew clean

    ./gradlew build

    ./gradlew assembleDebug

    #Install APK on device / emulator
    echo "installDebug...\n"

    ./gradlew installDebug

还可以使用。卸载以前的任何版本

  `./gradlew uninstallDebug`

你可以像下面这样在设备/模拟器上启动你的主活动

#Launch Main Activity
adb shell am start -n "com.sample.androidbuildautomationsample/com.sample.androidbuildautomationsample.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

对于想要从Linux系统加载apk并在其上运行React本机应用程序的人。 我已经给出了路径,其中android应用程序驻留以及。这样需要查找apk文件的人就可以去查看了。

adb -s 434eeads install android/app/build/outputs/apk/debug/app-debug.apk

用于重新安装手机上的android应用程序

adb -s 434eeads install -r android/app/build/outputs/apk/debug/app-debug.apk

s ->源代码/副号码

r ->重新安装 路径+文件名:android/app/build/outputs/apk/debug/app-debug.apk

它适用于react原生应用程序。