#android #cordova #ionic-framework #cordova-plugins #ionic-native
#Android #кордова #ionic-framework #cordova-плагины #ionic-native
Вопрос:
Мое приложение IONIC 5 использует множество плагинов cordova. Приложение работает отлично, когда я запускаю
ionic cordova run android -l
Но когда я запускаю
ionic cordova run android
Приложение может быть успешно создано, но все плагины cordova не запускаются. Точно так же, как плагины cordova не содержатся в приложении.
Пожалуйста, помогите мне решить эту проблему, спасибо.
Ниже приведен мой package.json
{
"name": "videochat",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.1.6",
"@angular/cdk": "^9.2.4",
"@angular/common": "~9.1.6",
"@angular/core": "~9.1.6",
"@angular/fire": "^5.4.2",
"@angular/forms": "~9.1.6",
"@angular/material": "^9.2.4",
"@angular/platform-browser": "~9.1.6",
"@angular/platform-browser-dynamic": "~9.1.6",
"@angular/router": "~9.1.6",
"@ionic-native/android-permissions": "^5.27.0",
"@ionic-native/app-version": "^5.28.0",
"@ionic-native/base64-to-gallery": "^5.28.0",
"@ionic-native/camera": "^5.28.0",
"@ionic-native/core": "5.27.0",
"@ionic-native/crop": "^5.28.0",
"@ionic-native/fcm": "^5.28.0",
"@ionic-native/file": "^5.28.0",
"@ionic-native/firebase": "^5.28.0",
"@ionic-native/in-app-browser": "^5.28.0",
"@ionic-native/insomnia": "^4.20.0",
"@ionic-native/ionic-webview": "^5.28.0",
"@ionic-native/keyboard": "^5.28.0",
"@ionic-native/local-notifications": "^5.28.0",
"@ionic-native/lottie-splash-screen": "^5.28.0",
"@ionic-native/native-audio": "^5.28.0",
"@ionic-native/native-page-transitions": "^5.28.0",
"@ionic-native/native-ringtones": "^5.28.0",
"@ionic-native/screen-orientation": "^5.28.0",
"@ionic-native/screenshot": "^5.28.0",
"@ionic-native/splash-screen": "5.24.0",
"@ionic-native/status-bar": "5.24.0",
"@ionic-native/vibration": "^5.28.0",
"@ionic/angular": "^5.0.0",
"@material-ui/core": "^4.10.1",
"@ngrx/store": "^9.2.0",
"@ngxs/storage-plugin": "^3.6.2",
"@ngxs/store": "^3.6.2",
"audiotoggle": "^1.0.0",
"axios": "^0.19.2",
"com.telerik.plugins.nativepagetransitions": "^0.7.0",
"compare-func": "^2.0.0",
"cordova-plugin-add-swift-support": "^1.7.2",
"cordova-plugin-android-permissions": "^1.0.2",
"cordova-plugin-androidx": "^2.0.0",
"cordova-plugin-androidx-adapter": "^1.1.1",
"cordova-plugin-audiotoggle": "^1.0.3",
"cordova-plugin-carthage-support": "^1.0.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-insomnia": "^4.3.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-iosrtc": "^6.0.13",
"cordova-plugin-media": "^5.0.3",
"cordova-plugin-native-ringtones": "^0.2.5",
"cordova-plugin-nativeaudio": "^3.0.9",
"cordova-plugin-screen-orientation": "^3.0.2",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-vibration": "^3.1.1",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-plugin-x-toast": "^2.7.2",
"es6-promise-plugin": "^4.2.2",
"extsprintf": "^1.4.0",
"firebase": "^7.19.1",
"jquery": "3.5.1",
"lodash": "^4.17.20",
"lottie-web": "^5.7.3",
"moment": "^2.26.0",
"native-run": "^1.0.0",
"ng-lottie": "^0.3.2",
"ngx-lottie": "^6.4.0",
"properties-parser": "^0.3.1",
"qrcode": "^1.4.4",
"rxjs": "~6.5.1",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/architect": "~0.900",
"@angular-devkit/build-angular": "~0.901.5",
"@angular/cli": "~9.1.5",
"@angular/compiler": "~9.1.6",
"@angular/compiler-cli": "~9.1.6",
"@angular/language-service": "~9.1.6",
"@ionic/angular-toolkit": "^2.1.1",
"@ionic/lab": "3.1.7",
"@types/jasmine": "^3.5.12",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.5.1",
"@types/node": "^14.6.0",
"codelyzer": "^5.1.2",
"com.darktalker.cordova.screenshot": "^0.1.6",
"cordova-android-support-gradle-release": "^3.0.1",
"cordova-base64-to-gallery": "^4.1.3",
"cordova-plugin-android-enumeratedevices": "git https://github.com/OpenVidu/cordova-plugin-android-enumeratedevices.git",
"cordova-plugin-app-version": "^0.1.9",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-crop": "^0.4.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-fcm-with-dependecy-updated": "^7.1.1",
"cordova-plugin-inappbrowser": "^4.0.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^5.0.0",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-plugin-wkwebview-engine": "^1.2.1",
"firebase-tools": "^8.7.0",
"fuzzy": "^0.1.3",
"inquirer": "^6.2.2",
"inquirer-autocomplete-prompt": "^1.0.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"jetifier": "^1.6.6",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"openvidu-browser": "2.14.0",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "^6.1.3",
"typescript": "~3.8.3",
"xcode": "^3.0.1"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-android-enumeratedevices": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-android-permissions": {},
"cordova-plugin-iosrtc": {
"MANUAL_INIT_AUDIO_DEVICE": "FALSE"
},
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-file": {},
"cordova-plugin-x-toast": {},
"cordova-plugin-androidx": {},
"cordova-plugin-audiotoggle": {},
"cordova-plugin-nativeaudio": {},
"cordova-plugin-native-ringtones": {},
"cordova-plugin-screen-orientation": {},
"cordova-plugin-insomnia": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-fcm-with-dependecy-updated": {
"ANDROID_FCM_VERSION": "19.0.0",
"ANDROID_GRADLE_TOOLS_VERSION": "3.5.3",
"ANDROID_GOOGLE_SERVICES_VERSION": "4.3.3",
"ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher"
},
"cordova-plugin-app-version": {},
"com.darktalker.cordova.screenshot": {},
"cordova-base64-to-gallery": {},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27. "
},
"cordova-plugin-crop": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-network-information": {},
"cordova-android-support-gradle-release": {
"ANDROID_SUPPORT_VERSION": "27. "
},
"com.telerik.plugins.nativepagetransitions": {},
"cordova-plugin-vibration": {}
},
"platforms": []
}
}
Ниже приведен мой config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.chat" ios-CFBundleVersion="0.1.11" version="0.0.6" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Coach</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="22" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="StatusBarOverlaysWebView" value="true" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
<preference name="KeyboardResize" value="true" />
<preference name="KeyboardResizeMode" value="native" />
<preference name="SplashScreen" value="screen" />
<preference name="ShowSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="FadeSplashScreen" value="true" />
<resource-file src="resources/raw/incoming-call.mp3" target="incoming-call.mp3" />
<platform name="android">
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<allow-intent href="market:*" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
<icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
<icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
<icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
<splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
<splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
<splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
<splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
<splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
<splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
<splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
<splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
<splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
<config-file mode="merge" parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</config-file>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
<platform name="ios">
<preference name="target-device" value="universal" />
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<preference name="UseSwiftLanguageVersion" value="4.2" />
<preference name="UseLegacySwiftLanguageVersion" value="true" />
<preference name="AllowBackForwardNavigationGestures" value="true" />
<icon height="57" src="resources/ios/icon/icon.png" width="57" />
<icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
<icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
<icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
<icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
<icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
<icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
<icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
<icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
<icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
<icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
<icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
<icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
<icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
<icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
<icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
<icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
<icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
<icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
<icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
<icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
<icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
<icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
<icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
<icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
<icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
<splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
<splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
<splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
<splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
<splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
<hook src="hooks/iosrtc-swift-support.js" type="after_platform_add" />
<config-file parent="NSCameraUsageDescription" target="*-Info.plist">
<string>อนุญาตเข้าถึงกล้องของคุณ</string>
</config-file>
<config-file parent="NSPhotoLibraryAddUsageDescription" target="*-Info.plist">
<string>อนุญาตเข้าถึงอัลบั้มรูปภาพของคุณ</string>
</config-file>
<config-file parent="NSPhotoLibraryUsageDescription" target="*-Info.plist">
<string>อนุญาตเข้าถึงอัลบั้มรูปภาพของคุณ</string>
</config-file>
<config-file parent="NSContactsUsageDescription" target="*-Info.plist">
<string>OpenVidu needs access to contacts</string>
</config-file>
<config-file parent="NSMicrophoneUsageDescription" target="*-Info.plist">
<string>OpenVidu needs access to your microphone</string>
</config-file>
<icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
<splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
<splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
<splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
</platform>
<allow-navigation href="http://localhost:8100" sessionid="fc4d5416" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.4" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.3" />
<plugin name="cordova-plugin-android-permissions" spec="1.0.2" />
<plugin name="cordova-plugin-device" spec="^2.0.3" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.2.0" />
<plugin name="cordova-plugin-iosrtc" spec="^6.0.11" />
<preference name="WKWebViewOnly" value="true" />
<allow-navigation href="http://192.168.1.178:8100" sessionid="aa93b197" />
<plugin name="cordova-plugin-android-enumeratedevices" spec="../cordova-plugin-android-enumeratedevices" />
<plugin name="cordova-android-support-gradle-release" spec="^3.0.1">
<variable name="ANDROID_SUPPORT_VERSION" value="27. " />
</plugin>
</widget>
Комментарии:
1. Пожалуйста, добавьте сообщение об ошибке, которое вы получаете в своем вопросе. Кроме того, посмотрев на ваш config.xml файл, похоже, что плагин камеры не установлен. Попробуйте переустановить его и убедитесь, что его запись существует в package.json amp; config.xml
2. Еще одна вещь, которая очень беспокоит, это то, что у вас есть большинство зависимостей вашего плагина cordova
devDependencies
, объявленных в вашем файле package.json.. Что неправильно… Эти файлы плагинов не будут скопированы после сборки вашего приложения.. Переместите их вdependencies
Ответ №1:
После того, как я потратил более 10 часов на устранение проблемы. Я нашел журнал ошибок в Android Studio:
gap_init called from restricted origin: app://localhost
Я сравниваю с другим приложением Ionic, источником которого является «http://localhost «
Поэтому я меняю источник на «http://localhost «
Я знаю, что это решение — неправильный способ сделать. Но на данный момент это может решить проблему.
У кого-нибудь есть лучший способ назначить origin в config.xml
?
Комментарии:
1. Я боролся с плагином сканера штрих-кодов, не подключенным к Android. Ваш пост показал мне способ решить мою проблему. Чтобы разрешить origin, вы должны добавить это в config.xml
<allow-navigation href="app://localhost" />