-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[android] Outdated configuration tutorial in readme (?) #21
Comments
I ended up with the following configuration (androidx targeted):
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)
}
<?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>
+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);
+ }
+}
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:
<?xml version='1.0' encoding='utf-8'?>
<resources>
<!-- ... _>
- <string name="custom_url_scheme">com.example</string>
</resources> Some clarificationsTo 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 + multidexI 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 capacitorAlso, Capacitor has deeplink url schemes configured by default within Android (hence the - <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 |
getting this error " error: failed processing manifest." |
@raosaddam You can try the following: In Android Studio click |
@tafelnl Thank you for replying. |
Ah I see, the docs are missing the following steps:
|
That worked. Thank you so much |
The official branch documentation tells you to install a set of dependencies. As seen in their documentation:
This differs pretty much from what the docs of this library are stating.
Is that intentional? Or is this a mistake?
The text was updated successfully, but these errors were encountered: