当我尝试通过命令行运行我的Cordova应用程序时。我的构建成功,但是在模拟器或设备上运行,这使我在命令行上出现错误
我在AndroidManifest.xml文件中指定了最低sdk版本
use-sdk android:minSdkVersion =“10” android:targetSdkVersion =“21”
在模拟器上,我正在运行API版本19,Android 4.4.2,在移动设备上,我正在运行Android 4.4.3,并在Sony Xperia ultra t2上启用了USB调试。
最佳答案
使用Visual Studio 2017和Cordova 7+时遇到了相同的问题,但是得出了不同的解决方案。 Cordova 现在在输出目录中创建子文件夹:/platforms/android/build/outputs/apk/
debug /android-debug.apk
当然,在findOutputApksHelper
脚本中的cordova的GenericBuilder.js(build.js现在仅继承我们正在寻找的方法)中,当然不会将该子目录添加到搜索掩码中:
.....
function findOutputApksHelper (dir, build_type, arch) {
var shellSilent = shell.config.silent;
shell.config.silent = true;
var ret = shell.ls(path.join(dir, '*.apk')).filter(function (candidate) {
.........
所以我这样改变了它:
..........
function findOutputApksHelper (dir, build_type, arch) {
var shellSilent = shell.config.silent;
shell.config.silent = true;
var subAPKMask = build_type + '\\*.apk';
var ret = shell.ls(path.join(dir, subAPKMask)).filter(function (candidate) {
............
也许对某人会有帮助,因为我花了两个小时的时间来找到那个。