简体   繁体   English

Flutter Firebase 分析 无数据

[英]Flutter Firebase Analytics No Data

So I have a Flutter app setup with Firebase and I can't figure out why no analytics show up in the Analytics tab.所以我有一个 Flutter 应用程序设置 Firebase 我不明白为什么分析选项卡中没有显示分析。

在此处输入图像描述

I have all the needed dependencies in my pubspec.yaml..我的 pubspec.yaml 中包含所有需要的依赖项。

  firebase_auth: ^3.3.6
  firebase_core: ^1.12.0
  firebase_storage: ^10.2.6
  flutter_cache_manager: ^3.0.1
  flutter_colorpicker: ^0.5.0
  flutter_hooks: ^0.18.0
  flutter_icons: ^1.1.0
  flutter_launcher_icons: ^0.9.0
  flutter_local_notifications: ^9.2.0
  firebase_remote_config: ^1.0.2
  firebase_analytics: ^9.1.0
  firebase_crashlytics: ^2.5.1

Here is my current build.gradle android level.这是我当前的 build.gradle android 级别。

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Here is my current build.gradle app level.这是我当前的 build.gradle 应用级别。

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.mypackage.name"
        minSdkVersion 20
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.4.1'
}

Everything else I use in Firebase seems to log events fine (firestore, storage, etc).我在 Firebase 中使用的其他所有内容似乎都可以很好地记录事件(firestore、存储等)。 I've tried messing with the dependencies in the build.gradle files in the Android project but no luck there.我试过弄乱 Android 项目中的 build.gradle 文件中的依赖项,但没有成功。 Made sure my google-services.json was up to date.确保我的 google-services.json 是最新的。 Any idea what I've done wrong?知道我做错了什么吗? Thanks!谢谢!

My issue is I am upgrading my flutter app to have latest Firebase plugin using the OLD firebase project.我的问题是我正在升级我的 flutter 应用程序以使用旧的 firebase 项目获得最新的 Firebase 插件。

I solve my issue by creaet a new firebase project in the firebase console and use:我通过在 firebase 控制台创建一个新的 firebase 项目并使用来解决我的问题:

flutterfire configure

to connect my flutter app to the new firebase project.将我的 flutter 应用程序连接到新的 firebase 项目。

Than it works.比它有效。

Notes: Preverious I have already checked the installation of google services, and also set allow debug view using adb shell. But turn out it doesn't not work even I did all the checking.注意:之前我已经检查了谷歌服务的安装,并且还使用 adb shell 设置了允许调试视图。但是即使我做了所有检查,它也不起作用。

Hope this could help if you are facing the same issue.如果您遇到同样的问题,希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM