skip to Main Content

I´m trying to integrate google pay but the button doesn’t appears, i create another project to test in this is the error i got.

in the emulator the button at least appears but in my phone not.

Edit: I just discover that in emulator with API 30 doesn’t work but 31 and 33 it does.

I’m guessing that is because of my country, because in the emulator it work just fine, but when i test in my phone the button don’t show up. i live in Venezuela when i tested the app with a friend in Chile it works fine on his phone.

debugging the app in my phone i got this:

W/Activity(27610): PerfMonitor: Slow Operation: Activity com.example.gpay/.MainActivity onDestroy took 202ms
D/AppScoutStateMachine(27610): 27610-ScoutStateMachinecreated
D/DecorView[](27610): getWindowModeFromSystem  windowmode is 1
D/SurfaceView(27610): UPDATE null, mIsCastMode = false
D/SurfaceView(27610): UPDATE Surface(name=SurfaceView[com.example.gpay/com.example.gpay.MainActivity])/@0xffd4333, mIsProjectionMode = false
D/SurfaceControl(27610): nativeSetScreenProjection ===> setScreenProjection

The google pay button who needs the json in assets:

            GooglePayButton(
              paymentConfigurationAsset:
                  'default_payment_profile_google_pay.json',
              paymentItems: _paymentItems,
              type: GooglePayButtonType.pay,
              margin: const EdgeInsets.only(top: 15.0),
              onPaymentResult: print,
              loadingIndicator: const Center(
                child: CircularProgressIndicator(),
              ),
            ),

2

Answers


  1. You need to declare your resources in pubspec.yaml:

    flutter:
      assets:
        - assets/default_payment_profile_google_pay.json
    

    And in code:

    paymentConfigurationAsset: 'assets/default_payment_profile_google_pay.json',
    
    Login or Signup to reply.
  2. in pubspec.yaml file add:

    flutter:
      assets:
        - assets/
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search