0

I'm trying to integrate Stripe payments to mobile app in .NET MAUI and after a successful payment I want to redirect user back to the app. I'm trying to test the deep links with command adb shell am start -W -a android.intent.action.VIEW -d "degano://stripe-payment" and keep getting Unable to instantiate activity ComponentInfo error. Full error message :

Java.Lang.RuntimeException: 'Unable to instantiate activity ComponentInfo{com.apatinisbruksnys.degano/com.apatinisbruksnys.degano.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.apatinisbruksnys.degano.MainActivity" on path: DexPathList[[zip file "/data/app/~~pcq2cekAixcAykcMb-4nEw==/com.apatinisbruksnys.degano-26ZKCVT8DSgXymDIU-5QrQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~pcq2cekAixcAykcMb-4nEw==/com.apatinisbruksnys.degano-26ZKCVT8DSgXymDIU-5QrQ==/lib/x86_64, /data/app/~~pcq2cekAixcAykcMb-4nEw==/com.apatinisbruksnys.degano-26ZKCVT8DSgXymDIU-5QrQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]

Not sure if what I'm doing even works and would appreciate any help!

My AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:networkSecurityConfig="@xml/network_security_config" android:allowBackup="true" android:icon="@mipmap/logo_inapp_notext_whitebg" >
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDw5emwFV4oym-7c68mXqJIGxN5pboVwZQ" />
        <!-- Add the following intent filter to handle the custom URL scheme -->
        <activity android:name=".MainActivity"
                  android:exported="true">
            <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="degano"
                      android:host="stripe-payment" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

My MainActivity.cs

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Degano.Handlers;

namespace degano;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        
        Intent intent = Intent;
        String action = intent.Action;
        String scheme = intent.Scheme;

        if (Intent.ActionView.Equals(action) && scheme.Equals("degano"))
        {
            //Uri data = intent.Data;
            // Handle the redirect
        }
    }
}

I tried looking at this question but could not understand how to apply it to my case.

  • You can try to change .MainActivity to your app package name.MainActivity. You can find the package name in the csproj file. And add the intent filter attribute to the MainActivity class too. – Liyun Zhang - MSFT Apr 05 '23 at 08:57

0 Answers0