Search code examples
androidtoastacra

Error:(12, 32) error: attribute value must be constant when declaring String for toast for ACRA toast


I'm trying to introduce the ACRA lib in my library project. When I set up the String for the toast, I get a "Attribute value must be a constant" error. Please see attached screen-shots enter image description here

and the R.string.crash_toast_text: enter image description here

Please note that these lines of code are from here

https://github.com/ACRA/acra/wiki/AdvancedUsage#toast-notification


Solution

  • Based on CommonsWare 18 answer, I made it work. Here is a sample code if anyone gets stuck in the same situation:

     final ACRAConfiguration config = ACRA.getNewDefaultConfig(this);
    
        try {
            config.setMode(ReportingInteractionMode.TOAST);
        } catch (ACRAConfigurationException e) {
            e.printStackTrace();
        }
    
        config.setResToastText(R.string.crash_toast_text);
        ACRA.init(this, config);