相关疑难解决方法(0)

Android:Branch.io教程:Branch.getAutoInstance(this);

我想让Branch.io在Android上运行,但我遇到了:

myapplication.MainActivity cannot be cast to android.app.Application
Run Code Online (Sandbox Code Playgroud)

然后我改变了:

Branch.getAutoInstance(this);
Run Code Online (Sandbox Code Playgroud)

至:

Branch.getInstance();
Run Code Online (Sandbox Code Playgroud)


onCreate活动中.

然后我得到:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean io.branch.referral.Branch.initSession(io.branch.referral.Branch$BranchReferralInitListener, android.net.Uri, android.app.Activity)' on a null object reference
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
Run Code Online (Sandbox Code Playgroud)

你能帮助我完成基本的运行吗?

以下是我的AndroidManifest.xml :(注意:我的应用程序代码中添加了branch_key)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.x.myapplication">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_xxxxxxxxxxxxxxx" />

        <activity android:name=".MainActivity">
            <intent-filter>
                <data android:scheme="yourapp" android:host="open" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name="io.branch.referral.InstallListener" …
Run Code Online (Sandbox Code Playgroud)

branch.io

6
推荐指数
1
解决办法
2855
查看次数

标签 统计

branch.io ×1