再次删除并添加平台后,Cordova 无法在 Android 上运行
Posted
技术标签:
【中文标题】再次删除并添加平台后,Cordova 无法在 Android 上运行【英文标题】:Cordova not running on Android after removing and adding platform again 【发布时间】:2017-12-19 17:40:23 【问题描述】:在旧的 android 设备 (Android 4.1.2) 上运行 Ionic 时遇到一些问题,然后我删除并再次添加了 Android 平台,但之后我无法再在该设备上运行。
我使用的命令:
% sudo cordova run android -l -c --stacktrace
我得到了什么:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 21.435 secs
Error: /Users/francisco/Projetos-Ionic/Jungery/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:178: error: cannot find symbol
intentScan.putExtra(Intents.Scan.SHOW_FLIP_CAMERA_BUTTON, obj.optBoolean(SHOW_FLIP_CAMERA_BUTTON, false));
^
symbol: variable SHOW_FLIP_CAMERA_BUTTON
location: class Scan
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:179: error: cannot find symbol
intentScan.putExtra(Intents.Scan.SHOW_TORCH_BUTTON, obj.optBoolean(SHOW_TORCH_BUTTON, false));
^
symbol: variable SHOW_TORCH_BUTTON
location: class Scan
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:180: error: cannot find symbol
intentScan.putExtra(Intents.Scan.TORCH_ON, obj.optBoolean(TORCH_ON, false));
^
symbol: variable TORCH_ON
location: class Scan
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:181: error: cannot find symbol
intentScan.putExtra(Intents.Scan.SAVE_HISTORY, obj.optBoolean(SAVE_HISTORY, false));
^
symbol: variable SAVE_HISTORY
location: class Scan
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:183: error: cannot find symbol
intentScan.putExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, "" + obj.optLong(RESULTDISPLAY_DURATION));
^
symbol: variable RESULT_DISPLAY_DURATION_MS
location: class Scan
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:192: error: cannot find symbol
intentScan.putExtra(Intents.Scan.ORIENTATION_LOCK, obj.optString(ORIENTATION));
^
symbol: variable ORIENTATION_LOCK
location: class Scan
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:254: error: cannot find symbol
intentEncode.setAction(Intents.Encode.ACTION);
^
symbol: variable Encode
location: class Intents
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:255: error: cannot find symbol
intentEncode.putExtra(Intents.Encode.TYPE, type);
^
symbol: variable Encode
location: class Intents
/Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:256: error: cannot find symbol
intentEncode.putExtra(Intents.Encode.DATA, data);
^
symbol: variable Encode
location: class Intents
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/francisco/Projetos-Ionic/Jungery/platforms/android/src/com/bitpay/cordova/qrscanner/QRScanner.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
9 errors
FAILURE: Build failed with an exception.
Cordova 插件:
com.googlemaps.ios 2.5.0 "Google Maps SDK for iOS"
cordova-plugin-add-swift-support 1.7.0 "AddSwiftSupport"
cordova-plugin-android-permissions 1.0.0 "Permissions"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-nativegeocoder 2.0.4 "NativeGeocoder"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-qrscanner 2.5.0 "QRScanner"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-swift-support 3.1.1 "SwiftSupport"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-sqlite-storage 0.7.14 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.8 "BarcodeScanner"
如果我刚刚删除并再次添加它会出现什么问题?我可以看到有关 BarcodeScanner 插件的一些信息,但如果它在删除和添加 Android 平台之前运行良好,那又如何呢?
感谢任何提示:/
【问题讨论】:
您能指定您在项目中使用的插件列表吗?在phonegap plugin barcodescanner
存储库中报告了一个类似于您的错误github.com/phonegap/phonegap-plugin-barcodescanner/issues/510
谢谢你的回答,我刚刚把cordova插件列表放在了消息里。
【参考方案1】:
我解决了删除和再次安装 android 平台的问题,此外,我在另一个文件夹中从头开始安装了所有平台的 Android Studio,并再次创建了我的 ANDROID_HOME 变量。
【讨论】:
以上是关于再次删除并添加平台后,Cordova 无法在 Android 上运行的主要内容,如果未能解决你的问题,请参考以下文章
Cordova 平台添加:无法运行“java -version”
could not find an installed version of gradle either in android studio