Tipsi-stripe: Can't build `tipsi-stripe` for Android

Created on 9 Oct 2018  Â·  26Comments  Â·  Source: tipsi/tipsi-stripe

Before I have submitted the issue

[✓ ] I have read an installation guide
[✓ ] I know that for an iOS I need to install pods because I've read the installation guide
[✓ ] I have read a linking guide and checked that everything is OK like in manual linking guide
[✓ ] I know that before using tipsi-stripe I need to set options for my app as described in usage guide

The problem

When trying to run react-native run-android, I get:

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

Environment

  • tipsi-stripe version: 5.6.0
  • iOS or Android: Android
  • OS version: macOS
  • React-Native version: 0.57.1

Links to logs and sources

Create a GIST which is a paste of your _full_ logs or sources, and link them here.
If you are reporting a bug, _always_ include build or error logs!

For Android, please provide the following sections from android/app/build.gradle:

  • android.compileSdkVersion: 27
  • android.buildToolsVersion: 27.0.3
  • android.defaultConfig.minSdkVersion: 16
  • android.defaultConfig.targetSdkVersion: 26
wont-fix

Most helpful comment

Add this to build.gradle

compile (project(':tipsi-stripe')) {
        exclude group: 'com.google.android.gms'
        exclude group: 'com.google.firebase'
}

All 26 comments

@sfyfe31 this doesn't look like an error caused by a tipsi-stripe
you can check https://stackoverflow.com/questions/49112190/error-program-type-already-present-android-support-design-widget-coordinatorl maybe it contains solution

This is only happening with tipsi-stripe installed and linked. Confirmed with a bare RN app with just tipsi-stripe added, get the same error:

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.design.widget.CoordinatorLayout$1

FAILURE: Build failed with an exception.

Tried everything in that link. It builds, but then crashes when trying to run in the simulator.

Having the same problem but fixed when adding:

implementation 'com.android.support:design:27.1.0'

Based on stackoverflow answer.

@mcchrish adding that makes it build and run the app. One step forward. But when it tries to mount the first component which uses tipsi-stripe:

import React from 'react'
import stripe from 'tipsi-stripe'

import { Button } from './'

export default (props) => {
  const {
    onPress,
    platform
  } = props

  const ios = platform === 'ios'

  if (!stripe.deviceSupportsNativePay()) {
    return null
  } else if (!stripe.canMakeNativePayPayments()) {
    return (
      <Button
        onPress={stripe.openNativePaySetup}
        title={`Set-up ${ios ? 'Apple' : 'Google'}Pay`}
      />
    )
  } else {
    return (
      <Button
        onPress={onPress}
        title={`Tip with ${ios ? '' : 'Google'}Pay`}
      />
    )
  }
}

It crashes the app, saying AppName has stopped. The output from react-native log-android is just:

10-15 18:42:20.272  3494  3525 I ReactNativeJS: Running application "AppName" with appParams: {"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
10-15 18:42:47.910  3494  3494 D ReactNative: ReactInstanceManager.detachViewFromInstance()

Steps to replicate with a bare RN (0.57.3) repo:

react-native init AppName
cd AppName
npm i --save tipsi-stripe
react-native link tipsi-stripe

Updated android/app/build.gradle dependencies (to get past original build error):

dependencies {
    implementation 'com.android.support:design:27.1.0' <<< added
    compile project(':tipsi-stripe')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

Updated android/app/src/main/AndroidManifest.xml:

<application ...
  ...
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
</application>

Changed initial App.js to:

import React, {Component} from 'react'
import stripe from 'tipsi-stripe'
import {Text, View} from 'react-native';

export default class App extends Component {
  constructor (props) {
    super(props)

    this.state = { allowed: false }
  }

  async componentDidMount() {
    const allowed = await stripe.deviceSupportsNativePay()

    this.setState({ allowed })
  }

  render() {
    return (
      <View>
        <Text>Welcome to React Native!</Text>
        {this.state.allowed && <Text>Supports Native Pay</Text>}
      </View>
    );
  }
}

Added bundle identifier to Xcode

Runs fine in iOS simulator and shows Supports Native Pay.

When running react-native run-android, builds and installs, then crashes with AppName has stopped.

Could not find play-services-identity.aar (com.google.android.gms:play-services-identity:11.8.0).
Searched in the following locations:

[https://jcenter.bintray.com/com/google/android/gms/play-services-identity/11.8.0/play-services-identity-11.8.0.aar]
How can i solve this .. I added Tipsi_stripe As in the Documentation ..please help me out

Same here, any idea ?

adb logcat reports

0-24 20:21:57.971 28205 28205 D AndroidRuntime: Shutting down VM
10-24 20:21:57.973 28205 28205 E AndroidRuntime: FATAL EXCEPTION: main
10-24 20:21:57.973 28205 28205 E AndroidRuntime: Process: com.bigpixel.live, PID: 28205
10-24 20:21:57.973 28205 28205 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.app.ActivityThread.installProvider(ActivityThread.java:6285)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.app.ActivityThread.-wrap1(Unknown Source:0)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:105)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6541)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
10-24 20:21:57.973 28205 28205 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.bigpixel.live-NYdaNnGMrUDqCmONBcWF4w==/base.apk"],nativeLibraryDirectories=[/data/app/com.bigpixel.live-NYdaNnGMrUDqCmONBcWF4w==/lib/x86, /data/app/com.bigpixel.live-NYdaNnGMrUDqCmONBcWF4w==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
10-24 20:21:57.973 28205 28205 E AndroidRuntime:        ... 12 more

@sfyfe31 This should help you https://github.com/tipsi/tipsi-stripe/issues/295

Same issue on RN 0.57

@cybergrind Any ideas?

@ahmetabdi we haven't started digging into issues with RN 0.57 and don't have such plans in near term.
So we will be waiting for someone's PR or until we will upgrade RN to the most recent version

Thanks for quick reply, I can confirm this is not a 0.57 issue

It seems to be a conflict with react-native-maps when setting up with the following:

   implementation(project(':react-native-maps')){
       exclude group: 'com.google.android.gms', module: 'play-services-base'
       exclude group: 'com.google.android.gms', module: 'play-services-maps'
   }
   implementation 'com.google.android.gms:play-services-base:10.0.1'
   implementation 'com.google.android.gms:play-services-maps:10.0.1'

if you use the project-wide dependancies in https://github.com/react-community/react-native-maps/blob/master/docs/installation.md it works

I have just solved by adding this to android/app/build.gradle

defaultConfig {
    ...
    multiDexEnabled true
}
...
implementation 'com.android.support:design:27.1.0'

Had this issue on my project, I just had to update the tipsi-stripe version in the package.json :
"tipsi-stripe": "^6.1.2"

Previously, it was :
"tipsi-stripe": "^5.6.0"

Same error.

I was able to solve it by adding this to bundle.gradle

configurations.all {
            resolutionStrategy {
                force 'com.google.firebase:firebase-core:16.0.4'
                force 'com.google.firebase:firebase-iid:17.0.4'
                force 'com.google.android.gms:play-services-wallet:16.0.1'
            }
        }

Add this to build.gradle

compile (project(':tipsi-stripe')) {
        exclude group: 'com.google.android.gms'
        exclude group: 'com.google.firebase'
}

Add this to build.gradle

compile (project(':tipsi-stripe')) {
        exclude group: 'com.google.android.gms'
        exclude group: 'com.google.firebase'
}

This solution worked for me. Wish the docs were more thorough!

Add this to build.gradle

compile (project(':tipsi-stripe')) {
        exclude group: 'com.google.android.gms'
        exclude group: 'com.google.firebase'
}

I get an error when adding this.

```* What went wrong:
A problem occurred evaluating project ':app'.

Could not find method compile() for arguments [project ':tipsi-stripe', build_dheb7mx2ybpffnmffzvaa93s0$_run_closure1$_closure5@7fb6eca] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

Add this to build.gradle

compile (project(':tipsi-stripe')) {
        exclude group: 'com.google.android.gms'
        exclude group: 'com.google.firebase'
}

I get an error when adding this.

A problem occurred evaluating project ':app'.
> Could not find method compile() for arguments [project ':tipsi-stripe', build_dheb7mx2ybpffnmffzvaa93s0$_run_closure1$_closure5@7fb6eca] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

Try to change 'compile' to 'implementation'. Because this

WARNING: Configuration 'compile' is obsolete and has been replaced 
with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: 
http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: app

/app/bluild.gradle

dependencies {
...
implementation 'com.google.firebase:firebase-core:16.0.7'
}

fixed it for me

/app/bluild.gradle

dependencies {
...
implementation 'com.google.firebase:firebase-core:16.0.7'
}

fixed it for me

This worked for me as well

/app/bluild.gradle
dependencies {
...
implementation 'com.google.firebase:firebase-core:16.0.7'
}
fixed it for me

This worked for me as well

/app/bluild.gradle

dependencies {
...
implementation 'com.google.firebase:firebase-core:16.0.7'
}

fixed it for me

This does solve the issue, but I would like to know what is the use of firebase analytic on the stripe payment package?

/app/bluild.gradle

dependencies {
...
implementation 'com.google.firebase:firebase-core:16.0.7'
}

fixed it for me

Works for me, thx

Was this page helpful?
0 / 5 - 0 ratings