[英]How to add app-links on a Meteor-cordova project
I have a Meteor 1.8.1 which uses Cordova 7.1.4 for Android build.我有一个 Meteor 1.8.1,它使用 Cordova 7.1.4 构建 Android。 I want to add app-links so that when a user clicks on a
myApp.com
link the app is open instead of the browser.我想添加应用程序链接,以便当用户单击
myApp.com
链接时,应用程序打开而不是浏览器。
I have added the following to mobile-config.js:我在 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>
`)
When I try to compile the APK I get the following error:当我尝试编译 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>.
Generated /home/meteor/myApp/app/.meteor/local/cordova-build/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
looks like this:生成
/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>
You can do a meteor reset
which typically fixes these issues.您可以执行
meteor reset
,这通常可以解决这些问题。 It does the same thing as deleting the.meteor/local folder.它与删除 .meteor/local 文件夹的作用相同。
Something was wrong with the files on my .meteor/local
folder, deleted it, removed and added android platform and now it compiles correctly.我的
.meteor/local
文件夹中的文件有问题,删除它,删除并添加 android 平台,现在它可以正确编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.