react-native-payments icon indicating copy to clipboard operation
react-native-payments copied to clipboard

Android error: Cannot access zza class file

Open ms4ever7 opened this issue 5 years ago • 0 comments

Hello, After I've installed your plugin to add apple and android pay, my android build crashed with next message: cannot access zza class file for com.google.android.gms.common.internal.safeparcel.zza not found

Here is my app/gradle file:

import com.android.build.OutputFile

apply plugin: "com.android.application"
apply plugin: 'io.fabric'

project.ext.react = [
    entryFile: "index.js"
]

project.ext.envConfigFiles = [
		debug: ".env",
		release: ".env",
		stagingrelease: ".env.staging",
		productionrelease: ".env.production"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion project.compileSdkVersion
    buildToolsVersion project.buildToolsVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "pl.hypeme"
        minSdkVersion 21
        targetSdkVersion 28
				multiDexEnabled true
        versionCode 20
        versionName "2.1.3"
        ndk {
            abiFilters  "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
				missingDimensionStrategy 'react-native-camera', 'general'
				missingDimensionStrategy 'react-native-camera', 'mlkit'

    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }

    signingConfigs {
        release {
            storeFile file(keystoreProperties['STORE_FILE'])
            storePassword keystoreProperties['STORE_PASSWORD']
            keyAlias keystoreProperties['KEY_ALIAS']
            keyPassword keystoreProperties['KEY_PASSWORD']
        }
        debug {
            storeFile file('im_default_debug_keystore.jks')
            storePassword "android"
            keyAlias "key"
            keyPassword "android"
        }
    }
    buildTypes {
        release {
						minifyEnabled enableProguardInReleaseBuilds
						signingConfig signingConfigs.release
						proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
        debug {
            signingConfig signingConfigs.debug
        }
				stagingrelease {
						initWith release
						matchingFallbacks = ['release']
				}
				productionrelease {
						initWith release
						matchingFallbacks = ['release']
				}
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}


dependencies {
    implementation project(':react-native-image-crop-picker')
    implementation project(':react-native-webview')
    implementation project(':react-native-inappbrowser-reborn')
    implementation project(':react-native-network-info')
    implementation project(':react-native-payments')
    implementation project(':react-native-config')
    implementation project(':react-native-media-meta')
    implementation project(':rn-camera-roll')
    implementation project(':@sentry_react-native')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-screens')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-shared-element')
    implementation project(':react-native-date-picker')
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-iap')
    implementation project(':react-native-firebase')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-fetch-blob')
    implementation project(':react-native-video')
    implementation project(':react-native-camera')
    implementation project(':react-native-i18n')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:$project.supportLibVersion"
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:+'
		implementation("com.squareup.okio:okio:1.15.0")
		implementation("com.squareup.okhttp3:okhttp:3.12.1")
		implementation 'com.android.support:support-annotations:27.1.1'

		// Adding Google pay
		implementation 'com.google.android.gms:play-services-wallet:18.0.0'
    implementation 'com.android.support:appcompat-v7:24.1.1'

    implementation("com.crashlytics.sdk.android:crashlytics:2.9.7@aar") {
        transitive = true
		}


  implementation "com.google.android.gms:play-services-base:17.0.1"
  implementation "com.google.firebase:firebase-analytics:17.2.2"
	implementation "com.google.firebase:firebase-messaging:20.1.0"
	implementation 'com.android.support:multidex:1.0.3'

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

And android/gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
				maven { url 'https://maven.google.com' }
				maven { url 'https://maven.fabric.io/public' }
				google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.0.1'
				classpath 'io.fabric.tools:gradle:1.+'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        mavenLocal()
				maven { url 'https://maven.google.com' }
				maven { url "https://jitpack.io" }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
				configurations.all {
            resolutionStrategy {
                force 'com.google.android.gms:play-services-base:16.0.1'
            }
        }
    }
}

// project-wide versions : 
project.ext {
    compileSdkVersion=28
    buildToolsVersion="28.0.3"
    supportLibVersion = "27.1.1"

    googlePlayServicesVersion   = "16.0.1"
    googlePlayServicesVisionVersion = "15.0.2"
		firebaseCoreVersion="17.0.0"
		firebaseMessagingVersion="17.3.3"
		glideVersion = "4.8.0"
}

I've updated firebase and android plugins to last version but it did not help. Also tried to do stuff like:

  • Invalidate Caсhes and restart
  • Removing .ide & .idea files and open project again
  • Reinstalled all modules (with npx jetify after) and making link again

ms4ever7 avatar Feb 24 '20 12:02 ms4ever7