Comments (7)
I ended up with the following configuration (androidx targeted):
android\app\build.gradle
:
apply plugin: 'com.android.application'
android {
defaultConfig {
// ...
+ multiDexEnabled true
// ...
+ resValue "string", "applink_host", "example.app.link"
+ resValue "string", "applink_host_alternate", "example-alternate.app.link"
+ resValue "string", "deeplink_scheme", "example"
+ resValue "string", "branch_api_key", "key_live_example"
+ resValue "string", "branch_test_mode", "false"
// ...
}
}
dependencies {
+ implementation 'com.android.support:multidex:1.0.3'
+ // Branch: required for all Android apps
+ implementation 'io.branch.sdk.android:library:5.0.3'
+ // Branch: required if your app is in the Google Play Store (tip: avoid using bundled play services libs)
+ implementation 'com.google.firebase:firebase-appindexing:19.1.0' // App indexing
+ implementation 'com.google.android.gms:play-services-ads:19.4.0' // GAID matching
+ // Branch: optional
+ implementation 'androidx.browser:browser:1.2.0' // Chrome Tab matching (enables 100% guaranteed matching based on cookies)
}
android\app\src\main\AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<application
+ android:name=".CustomApplicationClass"
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">
<!-- ... -->
+ <meta-data
+ android:name="com.google.android.gms.ads.AD_MANAGER_APP"
+ android:value="true"/>
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="com.example.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ <!-- BEGIN BRANCH -->
+ <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
+ android:scheme="http"
+ android:host="@string/applink_host" />
+ <data
+ android:scheme="https"
+ android:host="@string/applink_host" />
+ <data
+ android:scheme="http"
+ android:host="@string/applink_host_alternate" />
+ <data
+ android:scheme="https"
+ android:host="@string/applink_host_alternate" />
+ </intent-filter>
+
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="@string/custom_url_scheme"/>
+ <data android:scheme="@string/deeplink_scheme"/>
</intent-filter>
+ <!-- END BRANCH -->
</activity>
+ <!-- BEGIN BRANCH -->
+ <!-- Branch init -->
+ <meta-data android:name="io.branch.sdk.BranchKey" android:value="@string/branch_api_key" />
+ <meta-data android:name="io.branch.sdk.TestMode" android:value="@string/branch_test_mode" />
+ <!-- END BRANCH -->
+
<!-- ... -->
</application>
<!-- ... -->
</manifest>
android\app\src\main\java\com\example\CustomApplicationClass.java
:
+package com.example;
+
+import android.content.Context;
+import androidx.multidex.MultiDex;
+import androidx.multidex.MultiDexApplication;
+import io.branch.referral.Branch;
+
+public class CustomApplicationClass extends MultiDexApplication {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ // Branch logging for debugging
+ Branch.enableLogging();
+
+ // Branch object initialization
+ Branch.getAutoInstance(this);
+ }
+
+ @Override
+ protected void attachBaseContext(Context base) {
+ super.attachBaseContext(base);
+ MultiDex.install(this);
+ }
+}
android\app\src\main\java\com\example\MainActivity.java
:
package com.example;
import android.content.Intent;
import android.os.Bundle;
import co.boundstate.BranchDeepLinks;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(
savedInstanceState,
new ArrayList<Class<? extends Plugin>>() {
{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
+ add(BranchDeepLinks.class);
}
}
);
}
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ this.setIntent(intent);
+ super.onNewIntent(intent);
+ }
}
Optionally you can probably safely delete the following:
android\app\src\main\res\values\strings.xml
<?xml version='1.0' encoding='utf-8'?>
<resources>
<!-- ... _>
- <string name="custom_url_scheme">com.example</string>
</resources>
Some clarifications
To me this configuration looks more up to date than the one in the readme. It might be that I have done some redundant configuration. But it works 100% now. So better safe than sorry.
androidx + multidex
I have made the choice to target AndroidX and support multidex. You can read more about multidex here: https://stackoverflow.com/questions/33588459/what-is-android-multidex It depends on your use case, but if you have a lot of dependencies installed like GM Services, Branch and Facebook for example, it seems like the right choice.
default custom_url_scheme by capacitor
Also, Capacitor has deeplink url schemes configured by default within Android (hence the custom_url_scheme
variable (which defaults to your package name) in strings.xml
. I think it does not make sense to keep this in your project when you use Branch, but that is up to you to decide. In the config above it is dropped however by simply removing the lines:
- <data android:scheme="@string/custom_url_scheme"/>
- <string name="custom_url_scheme">com.example</string>
Basically the only thing this does is removing the scheme com.example://
(ergo: your package name) from the supported schemes. Not very important, just some cleaning up.
from capacitor-branch-deep-links.
getting this error " error: failed processing manifest."
from capacitor-branch-deep-links.
I'm getting error in MainActivity.java
package co.boundstate does not exist
cannot find symbol class BranchDeepLinks
from capacitor-branch-deep-links.
@raosaddam You can try the following:
In Android Studio click File
> Sync Project with Gradle Files
and try to build again.
from capacitor-branch-deep-links.
@tafelnl Thank you for replying.
That didn't work either. Still same error
from capacitor-branch-deep-links.
Ah I see, the docs are missing the following steps:
- run
npm i capacitor-branch-deep-links
- run
npx cap sync
- In Android Studio click
File
>Sync Project with Gradle Files
and try to build again
from capacitor-branch-deep-links.
That worked. Thank you so much
from capacitor-branch-deep-links.
Related Issues (20)
- Provided for backwards compatibility for Capacitor v2 plugins. Capacitor v3 plugins should import the plugin directly. This "Plugins" export is deprecated in v3, and will be removed in v4. HOT 1
- Plugin incompatible with Gradle 8 HOT 10
- Problems with play-services-ads version HOT 7
- Can't generate deep link Error: BranchDeepLinks does not have web implementation HOT 1
- iOS Status 200 error (null) HOT 3
- getLatestReferringParams HOT 2
- Capacitor BranchDeepLinks.addListener is not working as a listener HOT 4
- Deep Linking Fails with Empty Referring Parameters HOT 6
- Type 'Branch' has no member 'setDMAParamsForEEA' HOT 9
- no setup docs for old versions
- iOS Network Request Invalid HOT 3
- Android Fatal Error - "You need to use a Theme.AppCompat theme" HOT 1
- Add support for custom deeplink image HOT 11
- Plugin crashes on ios 12 HOT 2
- Capacitor 4 support HOT 8
- 'scanInt32(representation:)' is only available in iOS 13.0 or newer HOT 5
- upgraded project to capacitor 4, ionic/xcode project will not compile HOT 2
- IOS Build not passing with version 5.0.0 of the plugin HOT 3
- Please update documentation HOT 3
- Make compatible with Capacitor 5 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capacitor-branch-deep-links.