Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined is not a function (evaluating 'RNIap.prepare()') #210

Closed
Gribadze opened this issue Jul 20, 2018 · 4 comments
Closed

Undefined is not a function (evaluating 'RNIap.prepare()') #210

Gribadze opened this issue Jul 20, 2018 · 4 comments
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed

Comments

@Gribadze
Copy link

Gribadze commented Jul 20, 2018

When I run react-native run-android --variant=release, function .prepare() is undefined
But when I run react-native run-android, .prepare() is a function
my android/build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1'
  }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        google()

        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.21.0'
            }
        }
    }
}

ext {
    compileSdkVersion = 27
    buildToolsVersion = '27.0.3'
    minSdkVersion = 16
    targetSdkVersion = 25
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android") || subproject.plugins.hasPlugin('android-library')) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

android/app/build.gradle

...
dependencies {
    implementation(project(':react-native-firebase')) {
        transitive = false
    }

    // RNFirebase required dependencies
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.android.gms:play-services-base:15.0.1"

    implementation "com.google.firebase:firebase-config:16.0.0"

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:27.1.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-vector-icons')
//    compile project(':react-native-navigation')
    implementation (project(':react-native-device-info')) {
        exclude group: "com.google.android.gms"
    }
    implementation project(':react-native-facebook-login')
    implementation(project(":react-native-google-signin")){
        exclude group: "com.google.android.gms"
    }
    implementation project(':react-native-i18n')
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation project(':react-native-svg')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-text-gradient')
    implementation project(':react-native-iap')
    implementation project(':react-native-fetch-blob')
}
...

Version of react-native-iap

1.2.4

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

RNIap.prepare is a function

Actual behavior

RNIap.prepare is undefined

Tested environment (Emulator? Real Device?)

both

Steps to reproduce the behavior

Run react-native run-android --variant=release, function .prepare() is undefined

@Gribadze
Copy link
Author

I've tried to import react-native-iap like this:
import RNIap from 'react-native-iap'
and
import * as RNIap from 'react-native-iap'

@JJMoon JJMoon added 🙏 help wanted Extra attention is needed 🤖 android Related to android labels Jul 20, 2018
@Gribadze
Copy link
Author

I've solved this problem, you may close this issue

@hyochan
Copy link
Member

hyochan commented Jul 20, 2018

@Gribadze Sorry for late comeback. Could you share your experience for those who might face same problem as you do? Thanks.

@hyochan hyochan closed this as completed Jul 23, 2018
@zelgan90
Copy link

zelgan90 commented Jul 30, 2018

@Gribadze could you please share the solution to this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants