Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACRA ignores sharedPreferences concerning acra #236

Closed
LittleHuba opened this issue Feb 11, 2015 · 28 comments
Closed

ACRA ignores sharedPreferences concerning acra #236

LittleHuba opened this issue Feb 11, 2015 · 28 comments

Comments

@LittleHuba
Copy link

ACRA 4.6.0RC2 ignores acra.enable, acra.disable, acra.syslog.enable, acra.user.email in the shared preferences. It copies them into the report but the have no inflouence on the behaviour of ACRA.

-With acra.enable or acra.disable set with either values ACRA will simply disable all reports
-It will send the syslog everytime, completely ignoring acra.syslog.enable
-The mail of the user is shown in the shared preferences but is not copied into the corresponding fields of the report

@william-ferguson-au
Copy link
Member

Post your ACRA config

@william-ferguson-au
Copy link
Member

I can't reproduce this.

if acra.disable is not defined, then ti is determined by acra.enable. If that is not defined, then the default is ACRA is enabled.

if 'acra.disable' is defined then it determines whether ACRA is disabled.

@LittleHuba
Copy link
Author

Config:
@ReportsCrashes(
httpMethod = HttpSender.Method.PUT,
reportType = HttpSender.Type.JSON,
formUri = "https://couchdb.huberulrich.de/acra-ffshelf/_design/acra-storage/_update/report",
formUriBasicAuthLogin = "XXXXXXXXXX",
formUriBasicAuthPassword = "XXXXXXXXXX",
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.crash_toast_text,
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
resDialogOkToast = R.string.crash_dialog_ok_toast
)

I currently deactivated the possibility to stop acra from collecting since I want to make it mandatory.

For the other settings in the report:

temp1

But the mail field is still not set:
temp1

Also the syslogs are still collected and sent with the report. I honestly don't know whats up there.

@william-ferguson-au
Copy link
Member

Are you entering an email address or comment in the crash report dialog?
It doesn't look like you are.

And I don't think you can make collecting crash reports mandatory if you are using mode=dialog, because the user can just cancel the dialog. If you always want to report then use mode=Silent or mode=Toast.

@LittleHuba
Copy link
Author

In the posted report I have not entered a comment. But the commenting of reports works without any problems (Just tested it ;) ).
As far as I know, the mail should be set by the shared preference acra.user.email, which is set. Still ACRA won't take this preference and copy it into the corresponding fields of the report.

Probably I should be more clear. To say it in the easiest way: I want to make it as near to the standard android experience as possible. Which means ACRA is collecting and when the app crashes it asks the user to send the report. What I do not want is that users can completely disable acra. (If the don't want to make the app better they should at least have to cancel the dialog everytime it crashes ;) )

@william-ferguson-au
Copy link
Member

As far as I know, the mail should be set by the shared preference acra.user.email,

This is not correct.

The user email address is the oneentered by them into the crash report dialog.
If they provide a value then it is saved to acra.user.email and that value will be the default email address the next time the crash dialog is displayed.

@LittleHuba
Copy link
Author

Then please edit your wiki. This is definitely confusing!

Also if the email is entered in the dialog? Where should they enter it?
device-2015-02-11-135053

I only got a field for comments but nothing else?

I highly recommend to rewrite your wiki, since it seems not to be in sync with the actual state of the project. This whole chapter is completely wrong since I set my project up while reading it. https://github.com/ACRA/acra/wiki/AdvancedUsage#letting-your-users-control-acra

I assume I have to change the values programmatically by creating a onPreferenceChangedListener and editing the acraConfig if the corresponding preferences are changed?

@william-ferguson-au
Copy link
Member

That is what I followed this afternoon when I tested the behaviour of acra.enable/acra.disable.
What do you believe is incorrect?

It clearly shows you how to add those preferences into your PreferenceScreen and let the user change them. You don't need to change them programatically.

@LittleHuba
Copy link
Author

Here is part of my preferences.xml:

temp1

Changing those settings is not changing anything in the behaviour of ACRA. I do not know why that is the case but the are completely ignored. I exchanged the checkboxPreferences with SwitchPreferences which should make no problems since the values are still the same (Boolean).

@william-ferguson-au
Copy link
Member

So, do you get or not get sys logs?
What log do you get during crash? It will say one way or the other whether ACRA will give read logs.

It determines whether it can based upon:
if (prefs.getBoolean(ACRA.PREF_ENABLE_SYSTEM_LOGS, true) && (pm.hasPermission(Manifest.permission.READ_LOGS)) || Compatibility.getAPILevel() >= 16) {

As to the user email as I said before ti is determined based upon what the user enters into the dialog. The real question is why you don't appear to be getting the email field in your crash dialog.

@LittleHuba
Copy link
Author

I do get sys logs. ACRA is collecting them and sending them with the report. But I cannot disable sys logs.

It seems like ACRA isn't reading the defaultSharedPreferences but others.

That is an interesting question. I'm referencing ACRA via gradle so I haven't changed anything in the sources.

@william-ferguson-au
Copy link
Member

So, if you uncheck the preference for acra.syslog.enable and generate an exception, you get a crash report that contains sys logs?

Have you tried using a CheckboxPreference instead of SwitchPreference?

@LittleHuba
Copy link
Author

Yes that is exactly the case.

I already tried using CheckboxPreference but the result is still the same.

@LittleHuba
Copy link
Author

What I also found and what is quite curious:

temp1

See the one preference in the very first line. A preference without a name makes no real sense. Probably thats the problem.

@william-ferguson-au
Copy link
Member

Possibly, but I couldn't comment about how you have generated that. I can't even see the full preferences.

@william-ferguson-au
Copy link
Member

I suggest you put together a small project that demos the issue and post a link to it, so I can inspect.

@LittleHuba
Copy link
Author

I'm currently checking if there exists another preference file for my app. I'm still unable to get it working. First problem was that ACRA somehow didn't recognize my default settings file and created it's own named "default". I rectified this by explicitely stating my own preference file. But it still ignores the settings.

I'll create a project an upload it to github.

@LittleHuba
Copy link
Author

Here is the link to the project. It's my first project on GitHub so bear with me if something is not working.
This project is not the simplest possible but it's representing the structure of my current app in development. The problems are still the same. (can't deactivate syslog, dialog is not showing field for email)

You can set the values in the settings fragment. the about fragment is for triggering an exception. I'm developing on Android 5.0.x. This might be related to this problem, so keep this in mind if the error isn't occuring on your device.

https://github.com/LittleHuba/ACRATest

Hopefully you're able to fix this.

@william-ferguson-au
Copy link
Member

Can you please cut it down to a minimum project.
Only what is required in order to reproduce the problem.

And make it 100% clear how you are generating the uncaught exception. Explicitly throwing a runtime exception from a button press is the best option.

@LittleHuba
Copy link
Author

The project was tailored down to the absolute minimum. All the errors described above are still there.

@william-ferguson-au
Copy link
Member

It looks like you have 3 or four sub modules.
it is not clear to me which are relevant, or why they are relevant.
It is also not clear how you are forcing the uncaught exception to occur.
It doesn't seem to be using a standard build structure.
And there are build artifacts checked in.

All of that makes it less than clear how I should pick up your project,
build it and attempt to verify any failure and then rectify.
Help me, help you.

On Thu, Feb 12, 2015 at 12:13 PM, LittleHuba notifications@github.com
wrote:

The project was tailored down to the absolute minimum. All the errors
described above are still there.


Reply to this email directly or view it on GitHub
#236 (comment).

@LittleHuba
Copy link
Author

I uploaded a Android Studio Project so I assume you can also pull it with android studio.

It seems like you still have the old project. Please delete it and pull the new version. There should be only one module. When I'm fetching it, it gives me a dialog to delete a vcs root. Please discard this dialog. After that everything should be good to go.

The project consists of one module ('app') with one activity, which has one button, which throws an exception when clicked.

@LittleHuba
Copy link
Author

Any progress?

@william-ferguson-au
Copy link
Member

No. Maybe later this week.

On Tue, Feb 24, 2015 at 3:46 AM, LittleHuba notifications@github.com
wrote:

Any progress?


Reply to this email directly or view it on GitHub
#236 (comment).

@william-ferguson-au
Copy link
Member

OK 3 problems.

First is that you have configured sharedPreferencesName = "com.lh.acratest_preferences" but in your code you are populating settings = PreferenceManager.getDefaultSharedPreferences(this); ie the default SharedPreferences. Remove that section of your ACRA config and ACRA will read the user email that you are populating.

Second is that after closing the dialog, ACRA rewrites the CrashReport and takes an empty userEmail from the dialog. I will look into why that is.

Third is that the test for adding system logs is improperly formed, so that on a device of API 16 or greater it will always collect logs. I will fix that.

@LittleHuba
Copy link
Author

Thanks a lot! Trying it now.

@LittleHuba
Copy link
Author

Everything seems to be working now. Thanks a lot.

@william-ferguson-au
Copy link
Member

Excellent

On Wed, Feb 25, 2015 at 4:27 AM, LittleHuba notifications@github.com
wrote:

Everything seems to be working now. Thanks a lot.


Reply to this email directly or view it on GitHub
#236 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants