我想使用Windows命令行安装一个文件。首先,我想在编译完所有.jar文件后为Android应用程序创建一个.apk文件,而不使用Eclipse。
有人知道如何在不使用Eclipse的情况下,仅通过使用命令行就可以做到这一点吗?
我想使用Windows命令行安装一个文件。首先,我想在编译完所有.jar文件后为Android应用程序创建一个.apk文件,而不使用Eclipse。
有人知道如何在不使用Eclipse的情况下,仅通过使用命令行就可以做到这一点吗?
当前回答
对于想要从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原生应用程序。
其他回答
最简单的方法就是通过命令
adb install example.apk
如果你想要目标连接设备你可以添加参数" -d "
adb install -d example.apk
如果你连接了多个设备/模拟器,你会得到这个错误
Adb:错误:连接失败:超过一个设备/模拟器 - waiting for device -错误:超过一个设备/模拟器
为了避免这种情况,您可以通过下面的命令列出所有设备
adb devices
你会得到如下结果
C:\Windows\System32>adb devices
List of devices attached
a3b09hh3e device
emulator-5334 device
选择其中一个设备,并将参数添加到adb命令中,如下所示:“-s a3b09hh3e”
adb -s a3b09a6e install example.apk
同样作为一个提示,如果apk的路径很长,有一个空格,只需添加它在双引号之间,如
adb -s a3b09a6e install "c:\my apk location\here 123\example.apk"
这太简单了!
例如,我的apk文件位置是:d:\myapp.apk
运行cmd 导航到“platform-tools”文件夹(在SDK文件夹中) 启动模拟器设备(假设它的名字是5556:MyDevice) 在cmd中输入以下代码: Adb -s emultor -5556 install d:\myapp.apk
等一段时间就完成了!!
我在我的windows机器上使用这个脚本(将当前文件夹中的所有apks安装到所有可用设备)
Write-Host "Listing APKs..."
$List_Apks = New-Object System.Collections.ArrayList
Get-ChildItem -Path .\ -Filter *.apk -File -Name| ForEach-Object {
$apk_filename = [System.IO.Path]::GetFileName($_)
$List_Apks+=$apk_filename
$apk_filename
}
Write-Host "Found apks "$List_Apks.Length
Write-Host ""
$raw_list = adb devices
$array_lines = $raw_list.Split("\n")
Write-Host "Listing devices "
$List_Device_Ids = New-Object System.Collections.ArrayList
1..($array_lines.Length-2) | foreach {
$device_id = $array_lines[$_].Split([char]0x9)[0]
$List_Device_Ids+=$device_id
$device_id
}
Write-Host "Found devices "$List_Device_Ids.Length
0..($List_Device_Ids.Length-1) | foreach {
$device_id = $List_Device_Ids[$_]
0..($List_Apks.Length-1) | foreach {
$apk_file_name = $List_Apks[$_]
Write-Host "Installing " $apk_file_name "->" $device_id
adb -s $device_id install -r $apk_file_name
}
}
Write-Host "Endo"
保存为install-apks.ps1
然后是powershell:
powershell -executionpolicy bypass -File .\install-apks.ps1
按Win+R > cmd 导航到android-sdk windows文件夹中的platform-tools\ 亚洲开发银行类型 现在按照Mohit Kanada所写的步骤(确保你提到了。apk文件的整个路径,例如。d: \ android应用程序\ test.apk)
要安装调试(测试)apk,使用-t:
运行Build-Make项目
在app文件夹中查找最后生成的apk。
例子:
adb install -t C:\code\BackupRestore\app\build\outputs\apk\debug\app-debug.apk