pikaju / flutter-braintree

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.
https://pub.dev/packages/flutter_braintree
MIT License
64 stars 119 forks source link

Unhandled Exception: PlatformException #53

Closed prabavgts closed 1 year ago

prabavgts commented 3 years ago

Hello, when I call the below method

var request = BraintreeDropInRequest( tokenizationKey: tokenizationKey, collectDeviceData: true, googlePaymentRequest: BraintreeGooglePaymentRequest( totalPrice: '4.20', currencyCode: 'USD', billingAddressRequired: false, ), paypalRequest: BraintreePayPalRequest( amount: '4.20', displayName: 'Example company', ), cardEnabled: true, ); BraintreeDropInResult result = await BraintreeDropIn.start(request); if (result != null) { showNonce(result.paymentMethodNonce); }

I got the error below,

Unhandled Exception: PlatformException(error, Unable to find explicit activity class {com.example.flutter_animation/com.braintreepayments.api.dropin.DropInActivity}; have you declared this activity in your AndroidManifest.xml?, null, android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flutter_animation/com.braintreepayments.api.dropin.DropInActivity}; have you declared this activity in your AndroidManifest.xml?

HamzaMuazzam commented 3 years ago

did you find the solution ? if yes please guide me.

phanvankhaicd commented 3 years ago

In File Manifest if you have tools:node="replace" in application, replace it by tools:replace="android:label". And in Screen Shot 2021-05-26 at 5 50 15 PM

I replace ${applicationId} by appID Ex: your AppID com.example.appexample remove all symbol '' = com.example.appexample.braintree

It work for me!

emran92 commented 3 years ago

In File Manifest if you have tools:node="replace" in application, replace it by tools:replace="android:label".

Where did you write this? Can you please show? thanks.

4uzhoy commented 2 years ago

For future visitors: add tools into your manifest tag

<manifest
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:android="http://schemas.android.com/apk/res/android"
        package="your.package.name">

then input in application tag replace tool

 <application
            tools:replace="android:label"

after that add braintree activity

  <activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"
                  android:launchMode="singleTask">
            <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="${applicationId}.braintree" />
            </intent-filter>
        </activity>
pikaju commented 1 year ago

I think this is an alternative solution to the one provided in the README. If you think this should be fixed by the plugin itself, please let me know.