javascript - 如何在 Meteor-cordova 项目中添加应用程序链接
问题描述
我有一个 Meteor 1.8.1,它使用 Cordova 7.1.4 进行 Android 构建。我想添加应用程序链接,以便当用户单击myApp.com
链接时打开应用程序而不是浏览器。
我在 mobile-config.js 中添加了以下内容:
App.appendToConfig(`
<platform name="android">
<config-file target="app/src/main/AndroidManifest.xml" parent="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<activity android:name="MainActivity" android:label="@string/title_myApp" >
<intent-filter android:label="@string/filter_view_http_myApp">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="www.myApp.com" android:pathPrefix="/" />
<data android:scheme="https" android:host="myApp.com" android:pathPrefix="/" />
</intent-filter>
</activity>
</config-file>
</platform>
`)
当我尝试编译 APK 时,出现以下错误:
BUILD FAILED in 1s
27 actionable tasks: 4 executed, 23 up-to-date
=> Errors executing Cordova commands:
While building Cordova app for platform Android:
Error: /home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/gradlew: Command failed with exit code 1 Error output:
/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:100: AAPT: error: unexpected element <intent-filter>
found in <manifest><application>.
/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:111: AAPT: error: unexpected element <intent-filter>
found in <manifest><application>.
/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:130: AAPT: error: unexpected element <receiver> found
in <manifest><application><activity>.
/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:100: error: unexpected element <intent-filter> found
in <manifest><application>.
/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:111: error: unexpected element <intent-filter> found
in <manifest><application>.
/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:130: error: unexpected element <receiver> found in
<manifest><application><activity>.
生成/home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
的样子是这样的:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myApp.app"
android:hardwareAccelerated="true"
android:versionCode="10003"
android:versionName="1.0.3" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="28" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- for android -->
<!-- <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS"/> -->
<!-- <uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS"/> -->
<!-- <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> -->
<!-- <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /> -->
<!-- for Samsung -->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" /> <!-- for htc -->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT" /> <!-- for sony -->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" />
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE" /> <!-- for apex -->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT" /> <!-- for solid -->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE" /> <!-- for huawei -->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" /> <!-- for ZUK -->
<uses-permission android:name="android.permission.READ_APP_BADGE" /> <!-- for OPPO -->
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS" /> <!-- for EvMe -->
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ" />
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE" /> <!-- Required by older versions of Google Play services to create IID tokens -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.myApp.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.myApp.app.permission.C2D_MESSAGE" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:debuggable="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:supportsRtl="true" >
<activity
android:name="com.myApp.app.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/activity_name"
android:launchMode="singleTop"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:windowSoftInputMode="adjustResize" >
<intent-filter android:label="@string/launcher_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.adobe.phonegap.push.PushHandlerActivity"
android:exported="true"
android:permission="com.myApp.app.permission.PushHandlerActivity" />
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
<receiver android:name="com.adobe.phonegap.push.PushDismissedHandler" />
<service android:name="com.adobe.phonegap.push.FCMService" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.adobe.phonegap.push.PushInstanceIDListenerService" >
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.appsflyer.MultipleInstallBroadcastReceiver"
android:exported="true" />
<intent-filter android:label="@string/filter_view_http_myApp" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.myApp.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
<intent-filter android:label="@string/filter_view_http_myApp" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.myApp.com"
android:pathPrefix="/"
android:scheme="https" />
<data
android:host="myApp.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
<activity
android:name="com.myApp.app.ShareActivity"
android:label="@string/title_myApp" >
<receiver
android:name="com.appsflyer.MultipleInstallBroadcastReceiver"
android:exported="true" />
<intent-filter android:label="@string/filter_view_http_myApp" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.myApp.com"
android:pathPrefix="/"
android:scheme="https" />
<data
android:host="myApp.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
</activity>
<!--
FirebaseMessagingService performs security checks at runtime,
no need for explicit permissions despite exported="true"
-->
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" >
</receiver>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<service
android:name="com.google.android.gms.measurement.AppMeasurementJobService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.myApp.app" />
</intent-filter>
</receiver>
<!--
FirebaseInstanceIdService performs security checks at runtime,
no need for explicit permissions despite exported="true"
-->
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.myApp.app.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
解决方案
你可以做一个meteor reset
通常可以解决这些问题的方法。它与删除 .meteor/local 文件夹的作用相同。
推荐阅读
- c# - 使剑道 tabStrip 选项卡的内容可滚动
- ruby-on-rails - 查询导致有效性错误的多态关联
- javascript - 如何停止移动 Divs 离开文档的长度?香草JS
- php - 正则表达式:显示所有电话号码
- c++ - c++ std::vector "this" 是 "nullptr"
- sql - SQL Server 中的百分比列
- python - 将字符串列表转换为整数 PYTHON
- dart - 如何通过更改下拉项来更新列表视图
- asp.net - 使用从 cpanel 下载的文件运行 mvc Web 应用程序
- ios - CollectionView:如何使位于视图中心的单元格的单元格大小更大?