无法调用GoogleAnalyticsBridge.trackScreenView

时间:2018-05-11 19:48:33

标签: android firebase react-native react-native-android google-analytics-sdk

我有一台新的Mac并克隆了我们的项目仓库,但即使我没有改变代码中的任何内容,我也收到了这个错误。我的同事使用的相同代码(即使他们克隆了一个新代码)和我的旧Windows笔记本电脑也可以成功构建。它让我思考我的版本是否错误?

以下是版本: RN版本:

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

操作系统:Android

gradlew版本:Gradle 2.14.1

Java版:java version "1.8.0_172"

这里有完整的错误:

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)"
    ]
  }

机器人/的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'
    }
  }
}

最后,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'

所以我做了什么:

  • 已移除node_modules并再次npm install
  • ./gradlew --stacktrace :app:dependencies检查未对齐的版本,但由于我没有使用它们,我最终评论了google play services
  • 使用./gradlew --stacktrace :app:dependencies挖掘解决方案以对齐版本,但显然问题是因为Firebase,但我只使用Onesignal而不是Firebase。

我一直在尝试Stack Overflow和GitHub的解决方案,但无济于事。

0 个答案:

没有答案