3

Since ACRA.init can only be called once and ACRA.getConfig() and ACRA.getConfig().setFormUri(uri) are both deprecated.Is there any correct way to change formUri programatically, once ACRA has been already initialized?

In our development app we are testing against several environments and we have different formUris to store ACRA errors, so each time we change to a new environment we must reconfigure ACRA to send all the errors to that formUri.

Right now we are using ACRA.getConfig().setFormUri(uri).

But we are afraid that this won't be possible in the nearby future, so is there any alternative?

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

1

There are no plans to allow ACRA to be initialised multiple times. It would introduced unnecessary complexity into a component that you need to be as rock solid as possible.

But you still have the capability of setting the formUri programmatically. You can just set it only once.

You clearly have some event at runtime that knows/determines which environment you are in. So you could set a SharedPreference at that point outlining the target formUri. Restart the app and have the formUri come from the SharedPreference.

NB this is an extremely unusual use case. Why do you have a separate formUri for the different environments for the one app? Why not have a single error repo and filter reports based upon some attribute in the report, such as environment?

IMHO having separate error reporting servers for even dev and release versions of an app is a nett negative as it means there is one more thing that you have changed between dev and release that you didn't need to. Less moving parts, less complexity == greater robustness.

William
  • 20,150
  • 8
  • 49
  • 91
  • 1
    Ok, I understad the complexity you talk about, but in our circunstances it's simpler to have diferent environments/databases to store the errors and diferent formUris don't represent a problem when generating the release version because we have it all automatic. As the environment change is something only developers do, we will force an app restart in those cases. Thank you! – Sergio Ballestero Apr 29 '16 at 06:39
0

But we are afraid that this won't be possible in the nearby future

You are right, 4.9.0 removes setFormUri

So is there any alternative?

Currently not. You can watch the discussion here.

F43nd1r
  • 7,690
  • 3
  • 24
  • 62
0

The 5.2.0 version of ACRA will allow re-initialization, so the correct way will be to alter the configuration re-initialize.

Specifically, ACRA.init() will succeed but emit a stern warning for all inits after the first time, but it will throw away the old configuration and take settings from the new one.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Mike Hardy
  • 2,274
  • 3
  • 25
  • 57