React-native-iap: Undefined no es una función (evaluando 'RNIap.prepare ()')

Creado en 20 jul. 2018  ·  4Comentarios  ·  Fuente: dooboolab/react-native-iap

Cuando ejecuto react-native run-android --variant = release, la función .prepare () no está definida
Pero cuando ejecuto react-native run-android, .prepare () es una función
mi 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')
}
...

Versión de react-native-iap

1.2.4

Plataformas en las que enfrentó el error (¿IOS o Android o ambos?)

Androide

Comportamiento esperado

RNIap.prepare es una función

Comportamiento real

RNIap.prepare no está definido

Entorno probado (¿Emulador? ¿Dispositivo real?)

ambas cosas

Pasos para reproducir el comportamiento

Ejecute react-native run-android --variant = release, la función .prepare () no está definida

🙏 help wanted 🤖 android

Todos 4 comentarios

Intenté importar react-native-iap así:
importar RNIap desde 'react-native-iap'
y
importar * como RNIap desde 'react-native-iap'

Resolví este problema, puede cerrar este problema.

@Gribadze Lo siento por el regreso tardío. ¿Podría compartir su experiencia con aquellos que podrían enfrentar el mismo problema que usted? Gracias.

@Gribadze, ¿ podría compartir la solución a este problema?

¿Fue útil esta página
0 / 5 - 0 calificaciones