问题
I upgraded the ACRA library used by my application from 4.5.0 to 4.6.0 but I am getting a compilation error for formKey which used to work with 4.5.
Here is the declaration:
@ReportsCrashes(
formKey = "",
formUri = "",
socketTimeout = 10000,
httpMethod = org.acra.sender.HttpSender.Method.POST,
mode = ReportingInteractionMode.SILENT,
resDialogText = R.string.crash_dialog_text,
resDialogIcon = android.R.drawable.ic_dialog_info,
resDialogTitle = R.string.crash_dialog_title,
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
)
Here is the error:
Error:(19, 17) error: cannot find symbol method formKey()
I tried removing the formKey, as it is not used anymore, from the declaration but it's producing a new error after I did that.
回答1:
After checking the ACRA ChangeLog , it seems to be bug of ACRA in 4.6.0
PR#233 PR#235 Allowing the location of BuildConfig to be configurable to support Gradle build flavours. NB This is a breaking change IF your are capturing BuildConfig AND your Application class does not reside in the Java package defined in your original AndroidManifest manifest:package attribute. In that scenario you will need to explicitly configure 'buildConfigClass' in your ACRA config.
I just upgraded the dependecies to 4.6.2 and the error was gone. You also need to remove the formKey from the annotation declaration.
dependencies {
compile 'ch.acra:acra:4.6.2'
}
@ReportsCrashes(
formUri = "",
socketTimeout = 10000,
httpMethod = org.acra.sender.HttpSender.Method.POST,
mode = ReportingInteractionMode.SILENT,
resDialogText = R.string.crash_dialog_text,
resDialogIcon = android.R.drawable.ic_dialog_info,
resDialogTitle = R.string.crash_dialog_title,
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
)
来源:https://stackoverflow.com/questions/30157931/compilation-error-after-upgrading-from-acra-4-5-to-acra-4-6