Fabric/Crashlytics on Android - How to have two different crashlytics projects with the same package name?

蓝咒 提交于 2019-12-04 18:45:15

问题


I am developing an Android application and I want to have two different projects in Crashlytics / Fabric (debug and release).

I know that this is possible by having two different package names, but in my case, the package name of these two build types have to be the same.

Is there any possibility to have two crashlytics projects with the same package name?


回答1:


Hello I also had same questions months ago and I solved it myself. Hope my answer will help you.

You need 2 organizations with different crashlyticsApiKey for each of your project on fabric.

Then on your build.gradle file you will define manifestPlaceHolders

debug {
        manifestPlaceholders = [crashlyticsApiKey: 'your_api_key_for_debug_project_here']
    }

release {
        manifestPlaceholders = [crashlyticsApiKey: 'your_api_key_for_release_project_here']
    }

Then you will put this variable on meta-data at your AndroidManifest.xml file

<meta-data
        android:name="io.fabric.ApiKey"
        android:value="${crashlyticsApiKey}" />

That's all, now build your project both for relase and debug, you will see your app will registered for 2 different fabric account with same package nam




回答2:


There is also an option where you do not need to create multiple organizations. You can use the Fabric.Builder with appIdentifier(java.lang.String appIdentifier).

The only thing to do is replace the Crashlytics initialization from the documentation

Fabric.with(this, new Crashlytics());

with something like this:

final String trackingId = BuildConfig.APPLICATION_ID + ".tv";
Fabric fabric = new Fabric.Builder(this).kits(new Crashlytics()).appIdentifier(trackingId).build();
Fabric.with(fabric);

The second snippet uses projects APPLICATION_ID (package name) and adds a ".tv" to it.

NOTE: when you track your crashes this way, Crashlytics does not create the project by itself. It is important to have the project created manually (or having the project already created from another App with the same package name).



来源:https://stackoverflow.com/questions/36887058/fabric-crashlytics-on-android-how-to-have-two-different-crashlytics-projects-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!