1

I got a new Mac and cloned our project repo, but I'm getting this error even though I didn't change anything in the code. The same code that my colleagues use (even if they clone a new one) and my old Windows laptop and can be built successfully. It got me to think if my versions are wrong?

Here are the versions: RN versions:

react-native-cli: 2.0.1
react-native: 0.47.2

OS: Android

gradlew version: Gradle 2.14.1

Java version: java version "1.8.0_172"

Here's the full error:

Could not invoke GoogleAnalyticsBridge.trackScreenView

null

No static method zzamg()Lcom/google/android/gms/common/util/zzh; or its super classes (declaration of 'com.google/android.gms.common.util.zzh' appears in /data/app/my.com/unifi.mobile-2/base.apk) 

package.json:

"dependencies": {
    "axios": "^0.16.2",
    "color": "^1.0.3",
    "hoist-non-react-statics": "^1.2.0",
    "immutable": "^3.8.2",
    "jest-cli": "^22.4.3",
    "lodash": "^4.17.4",
    "lottie-react-native": "2.2.7",
    "moment": "^2.18.1",
    "native-base": "^2.3.1",
    "phone": "1.0.10",
    "prop-types": "^15.5.10",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.47.2",
    "react-native-animatable": "^1.2.3",
    "react-native-appsflyer": "^1.1.12",
    "react-native-autolink": "^1.4.0",
    "react-native-code-push": "^5.2.2",
    "react-native-code-push-saga": "^1.0.1",
    "react-native-collapsible": "^0.9.0",
    "react-native-confirmation-code-input": "git+https://github.com/Blurzschyter/react-native-confirmation-code-input.git#master",
    "react-native-dotenv": "^0.1.0",
    "react-native-dropdownalert": "^2.8.0",
    "react-native-easy-grid": "^0.1.15",
    "react-native-extended-stylesheet": "^0.4.0",
    "react-native-fbsdk": "0.6.3",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-google-analytics-bridge": "^5.6.3",
    "react-native-modal": "^2.5.0",
    "react-native-modal-dropdown": "^0.5.0",
    "react-native-onesignal": "^3.1.0",
    "react-native-pdf": "^2.0.6",
    "react-native-permissions": "^1.0.1",
    "react-native-progress": "^3.4.0",
    "react-native-scrollable-tab-view": "^0.6.7",
    "react-native-simple-store": "^1.3.0",
    "react-native-smart-corner-label": "^1.1.2",
    "react-native-splash-screen": "^3.0.6",
    "react-native-swipeout": "^2.3.3",
    "react-native-swiper": "^1.5.13",
    "react-native-vector-icons": "^4.4.2",
    "react-navigation": "1.0.0-beta.15",
    "react-redux": "^5.0.4",
    "redux": "^3.6.0",
    "redux-immutable": "^4.0.0",
    "redux-immutable-state-invariant": "^2.0.0",
    "redux-logger": "^3.0.1",
    "redux-persist-immutable": "^4.3.1",
    "redux-saga": "^0.15.3",
    "redux-saga-testing": "^1.0.5",
    "reselect": "^3.0.1",
    "rn-sliding-up-panel": "^1.1.10"
  },
  "devDependencies": {
    "babel-eslint": "^8.0.1",
    "babel-jest": "21.2.0",
    "babel-preset-react-native": "4.0.0",
    "eslint": "^4.8.0",
    "eslint-config-airbnb": "^15.1.0",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.4.0",
    "eslint-plugin-react-native": "^3.1.0",
    "jest": "22.0.4",
    "prettier": "^1.3.1",
    "prettier-eslint": "^6.2.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|react-navigation|native-base-shoutem-theme|@shoutem/theme|@shoutem/animation|@shoutem/ui)"
    ]
  }

android/build.gradle:

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

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

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

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {                                  // <-- Add this
            url 'https://maven.google.com/'
            name 'Google'
        }
        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-gcm:11.8.0'
      force 'com.google.android.gms:play-services-analytics:11.8.0'
      force 'com.google.android.gms:play-services-auth:11.8.0'
      force 'com.google.android.gms:play-services-location:11.8.0'
    }
  }
    }
}

project(':react-native-fbsdk') {
  configurations.all {
    resolutionStrategy {
      force 'com.facebook.android:facebook-android-sdk:4.22.1'
    }
  }
}

and lastly, android/app/build.gradle:

    apply plugin: "com.android.application"

import com.android.build.OutputFile

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        multiDexEnabled true
        applicationId "my.com.unifi.mobile"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 28
        versionName "2.3.3"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [onesignal_app_id: "0f9ad6b5-166d-434d-8b54-855aaf7e9a44",
                                onesignal_google_project_number: "REMOTE"]
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            storeFile file("my-release-key.keystore")
            storePassword 'webedigital'
            keyAlias 'webedigital'
            keyPassword 'webedigital'
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // 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]
            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 {
    compile project(':react-native-appsflyer')
    compile project(':react-native-code-push')
    compile project(':react-native-onesignal')
    compile project(':react-native-google-analytics-bridge')
    compile project(':lottie-react-native')
    compile project(':react-native-pdf')
    compile project(':react-native-fetch-blob')
//    compile 'com.google.android.gms:play-services-auth:11.+'
    // compile project(':react-native-fbsdk')
    compile(project(':react-native-fbsdk')){
      exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
    }
    compile "com.facebook.android:facebook-android-sdk:4.22.1"
    compile project(':react-native-splash-screen')
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.0.1"
    // compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.android.support:multidex:1.0.1'
}

// 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'

So what I did:

  • Removed node_modules and did npm install again
  • Ran ./gradlew --stacktrace :app:dependencies to check the unaligned versions but I ended up commenting out google play services since I'm not using them.
  • Dug up solutions to align versions using ./gradlew --stacktrace :app:dependencies but apparently that problem was because of Firebase but I'm only using Onesignal and not Firebase.

I've been trying solutions from Stack Overflow and GitHub but to no avail.

halfer
  • 19,824
  • 17
  • 99
  • 186
Compaq LE2202x
  • 2,030
  • 9
  • 45
  • 62

0 Answers0