简体   繁体   中英

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 在此处输入图片说明

and the R.string.crash_toast_text: 在此处输入图片说明

Please note that these lines of code are from here

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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