简体   繁体   English

Android - Firebase 分析在启用 minifyEnabled 和 shrinkResources 后未显示在仪表板上

[英]Android - Firebase analytics not showing on dashboard after enabling minifyEnabled & shrinkResources

I have enabled minifyEnabled & shrinkResources in my code.我在我的代码中启用了 minifyEnabled 和 shrinkResources。 After enabling I am not getting any analytics of that app version on Analytics dashboard.启用后,我没有在 Analytics 仪表板上获得该应用程序版本的任何分析。

Do I need to make any proguard changes for firebase analytics?我是否需要对 firebase 分析进行任何混淆更改?

build.gradle build.gradle

buildTypes {
        debug {
            
        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            firebaseCrashlytics {
                mappingFileUploadEnabled true
            }
        }
    }

First of all, try to add this to your proguard首先,尝试将其添加到您的混淆器中

-keep class com.google.analytics.** { *; }

Did you use any custom class for the source of the value you send?您是否使用任何自定义 class 作为您发送的值的来源? If yes then you should be adding that class to proguard as well如果是,那么您也应该将 class 添加到混淆器中

When minifyEnabled is set to true and shrinkResources is set to true in your Android project, it enables code and resource optimization during the build process.当您的 Android 项目中的 minifyEnabled 设置为 true 并且 shrinkResources 设置为 true 时,它会在构建过程中启用代码和资源优化。 However, this optimization can sometimes cause issues with certain libraries or frameworks, such as Firebase.但是,这种优化有时会导致某些库或框架出现问题,例如 Firebase。

To resolve the issue with Firebase not working when minifyEnabled and shrinkResources are set to true, you can try adding the necessary rules to the ProGuard configuration file (proguard-rules.pro) to keep the required Firebase classes and resources.要解决 Firebase 在 minifyEnabled 和 shrinkResources 设置为 true 时不起作用的问题,您可以尝试将必要的规则添加到 ProGuard 配置文件 (proguard-rules.pro) 以保留所需的 Firebase 类和资源。

Add the following rules to the proguard-rules.pro file:将以下规则添加到 proguard-rules.pro 文件中:

      # Keep the Firebase classes
-keep class com.google.firebase.** { *; }

# Keep the Play Services classes
-keep class com.google.android.gms.** { *; }

# Keep the Firebase options
-keepattributes Signature
-keepattributes *Annotation*
-keepclassmembers public class com.google.firebase.options.FirebaseOptions {
    public <fields>;
    public <methods>;
}

# Keep the Firebase database data classes
-keepclassmembers class * extends com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper {
    <fields>;
}

# Keep the Firebase Firestore classes
-keepnames class com.google.firebase.firestore.** { *; }

# Keep the Firebase Auth classes
   -keepnames class com.google.firebase.auth.** { *; }

Make sure to include the proguard-rules.pro file in your build.gradle file:确保在 build.gradle 文件中包含 proguard-rules.pro 文件:

android {
    // ...

    buildTypes {
        release {
            // ...
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

By adding these rules, you instruct ProGuard to keep the necessary Firebase classes and resources during the code and resource optimization process, ensuring that Firebase functions correctly even when minifyEnabled and shrinkResources are enabled.通过添加这些规则,您指示 ProGuard 在代码和资源优化过程中保留必要的 Firebase 类和资源,确保 Firebase 即使在启用 minifyEnabled 和 shrinkResources 时也能正常运行。

Note: If you are using other Firebase products such as Firebase Crashlytics or Firebase Analytics, you may need to add additional ProGuard rules specific to those products as well.注意:如果您使用其他 Firebase 产品,例如 Firebase Crashlytics 或 Firebase Analytics,您可能还需要添加特定于这些产品的额外 ProGuard 规则。 Refer to the Firebase documentation or the respective Firebase product documentation for the required ProGuard rules.有关所需的 ProGuard 规则,请参阅 Firebase 文档或相应的 Firebase 产品文档。

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

相关问题 谷歌分析 firebase 未显示 - Google analytics with firebase not showing Firebase 分析未显示最新版本 - Firebase Analytics not showing the latest release Firebase 分析仪表板 - 比较保存更改 - Firebase Analytics dashboard - Save changes in comparison iOS Firebase Crashlytics 未在仪表板中显示崩溃 - iOS Firebase Crashlytics not showing up crashes in Dashboard 选择加入后初始化 Firebase Analytics - Initialize Firebase Analytics after Opt-In 如何将 Firebase 分析数据添加到 Flutter 管理仪表板 - How to add Firebase Analytics data to a Flutter admin dashboard Firebase 分析在运行 android 应用程序时崩溃 - Firebase analytics crash while running android app 在 React-Native 中,Firebase-Crashlytics 日志未显示在 Firebase Crashlytics 仪表板上 - In React-Native the Firebase-Crashlytics log is not showing on Firebase Crashlytics dashboard Firebase 即使在启用存储后存储仍返回 412 错误 API - Firebase storage returning 412 error even after enabling storage API Android Firebase-Analytics:无法将 null 设置为 userid 和 userproperty - Android Firebase-Analytics : Not able to set null to userid and userproperty
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM