Android: unable to inject multiple <intent-filters>
Ma-ve opened this issue · 0 comments
edit:
The second I posted this question, I figured it out. Obviously, just move each intent-filter
to its own inject:
manifest:
- file: AndroidManifest.xml
target: manifest/application/activity
inject: |
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data deeplink="true" android:scheme="https" android:host="acc.my.domain.com" />
</intent-filter>
- file: AndroidManifest.xml
target: manifest/application/activity
inject: |
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data deeplink="true" android:scheme="https" android:host="acc.my.domain.eu" />
</intent-filter>
We're trying to have multiple sets of deeplink for different stages of an app.
Given the following AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.domain.my">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="com.domain.my.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<!-- If you need write access -->
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
</manifest>
We're (auto)building a separate app for local/staging, so we can verify the deep links properly work, without having to delete the production app.
Trying to inject multiple intent-filter
s doesn't work:
Given the following config.acc.yaml
for Trapeze:
android:
packageName: $PACKAGE_NAME
versionName: $MARKETING_VERSION
versionCode: $BUILD_NUMBER
manifest:
- file: AndroidManifest.xml
target: manifest/application/activity
inject: |
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data deeplink="true" android:scheme="https" android:host="acc.my.domain.com" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data deeplink="true" android:scheme="https" android:host="acc.my.domain.eu" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data deeplink="true" android:scheme="https" android:host="acc.my.domain.co.uk" />
</intent-filter>
res:
- path: values
file: strings.xml
text: |
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">MyDomain - Acc</string>
<string name="title_activity_main">MyDomain - Acc</string>
<string name="package_name">$PACKAGE_NAME</string>
<string name="custom_url_scheme">$PACKAGE_NAME</string>
</resources>
Will give the following output error(s):
[xmldom error] element parse error: Error: Hierarchy request error: Only one element can be added and only after doctype
And the following AndroidManifest.xml
as result:
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.domain.my">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="com.domain.my.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<!-- If you need write access -->
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
</manifest>
Is it possible to inject multiple intent-filter
s in any way? I've tried making them unique through <intent-filter android:autoVerify="true" android:order="10">
and decrementing the order, but no joy