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

Crash when exporting transactions on 1.4.3 #223

Closed
nodje opened this issue Sep 22, 2014 · 20 comments
Closed

Crash when exporting transactions on 1.4.3 #223

nodje opened this issue Sep 22, 2014 · 20 comments

Comments

@nodje
Copy link

nodje commented Sep 22, 2014

Basically, the stacktrace is saying:

NullPointerException: println needs a message at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:231)
at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExportAsyncTask.java:113)
at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExportAsyncTask.java:48)

Sounds pretty straightforward looking at the trace but I wonder why nobody has reported the bug earlier. It's a totally blocking bug for anyone using this app with the Gnucash desktop.

Could it be my distribution? MI UI 5

@fefe982
Copy link
Contributor

fefe982 commented Sep 22, 2014

Cannot reproduce this. However, I can see the problem in the code, and made a quick fix.

I'm also very interested in the stack trace printed before this crash, to see why the export failed. Can you find it?

@nodje
Copy link
Author

nodje commented Sep 22, 2014

Easy to reproduce for me, I just have to try an export ;)

It seemed to be the root cause of the export crash to me, but here's the handmade copy of the trace:

RuntimeException
...
NullPointerException: println needs a message at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:231)
at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExportAsyncTask.java:113)
at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExportAsyncTask.java:48)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
...5 more than I can't see.

Actually looking at the code, there's nothing to fix because
ExportAsyncTask:113 Log.e(TAG, e.getMessage()); does provide a message and so shoudn't crash.

The problem seems to come from the above line, 110, writeOutput(mExporter.generateExport());
which on my device produces an exception that, apparently, returns null on e.getMessage().

That's how I understand it. But I can't get more information then the stacktrace provided above.
Maybe I should check my phone status.

@codinguser
Copy link
Owner

It will indeed be difficult to find out why the export failed as the exception message is null in the first place. I've sometimes had issues like this which were specific to particular Android builds and not reproducible for anyone else. We need a deeper logging solution to catch this kinds of singular events.

The fix which @fefe982 has added will prevent the whole app from crashing, but still not fix why your QIF is not generated. From what version did you notice that you couldn't generate QIF anymore?

@nodje
Copy link
Author

nodje commented Sep 22, 2014

Right, e.getMessage() CAN be null, so it should tested beforehand.

I guess it was from the last version I updated to, so I guess 1.4.3.
But it could well be my phone.

I've got this Syslog app that allows me to send all the logs of my phone. I'll have a look quickly.

@nodje
Copy link
Author

nodje commented Sep 22, 2014

Problem seems to be related to my MI UI version:

09-22 15:45:20.288 W/System.err( 3630): java.lang.NullPointerException
09-22 15:45:20.318 W/System.err( 3630):     at libcore.icu.ICU.getCurrencySymbol(Native Method)
09-22 15:45:20.318 W/System.err( 3630):     at java.util.Currency.<init>(Currency.java:38)
09-22 15:45:20.318 W/System.err( 3630):     at java.util.Currency.getInstance(Currency.java:54)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.model.Money.<init>(Money.java:124)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.db.SplitsDbAdapter.buildSplitInstance(SplitsDbAdapter.java:99)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.db.SplitsDbAdapter.getSplitsForTransaction(SplitsDbAdapter.java:192)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.db.SplitsDbAdapter.getSplitsForTransaction(SplitsDbAdapter.java:208)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.db.TransactionsDbAdapter.buildTransactionInstance(TransactionsDbAdapter.java:299)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.db.TransactionsDbAdapter.getAllTransactionsForAccount(TransactionsDbAdapter.java:220)
09-22 15:45:20.318 W/System.err( 3630):     at org.gnucash.android.db.AccountsDbAdapter.buildAccountInstance(AccountsDbAdapter.java:245)
09-22 15:45:20.328 W/System.err( 3630):     at org.gnucash.android.db.AccountsDbAdapter.getAllAccounts(AccountsDbAdapter.java:395)
09-22 15:45:20.328 W/System.err( 3630):     at org.gnucash.android.export.ofx.OfxExporter.generateExport(OfxExporter.java:105)
09-22 15:45:20.328 W/System.err( 3630):     at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExporterAsyncTask.java:110)
09-22 15:45:20.328 W/System.err( 3630):     at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExporterAsyncTask.java:48)
09-22 15:45:20.328 W/System.err( 3630):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
09-22 15:45:20.328 W/System.err( 3630):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-22 15:45:20.328 W/System.err( 3630):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-22 15:45:20.328 W/System.err( 3630):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
09-22 15:45:20.328 W/System.err( 3630):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-22 15:45:20.328 W/System.err( 3630):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-22 15:45:20.328 W/System.err( 3630):     at java.lang.Thread.run(Thread.java:856)
09-22 15:45:20.328 E/dalvikvm( 3630): threadid=20: created from interp,name=AsyncTask #6
09-22 15:45:20.328 E/dalvikvm( 3630): threadid=15: exiting,name=AsyncTask #1
09-22 15:45:20.328 W/dalvikvm( 3630): threadid=15: thread exiting with uncaught exception (group=0x41ed5498)
09-22 15:45:20.328 E/dalvikvm( 3630): threadid=20: calling run(),name=AsyncTask #6
09-22 15:45:20.368 E/AndroidRuntime( 3630): FATAL EXCEPTION: AsyncTask #1
09-22 15:45:20.368 E/AndroidRuntime( 3630): java.lang.RuntimeException: An error occured while executing doInBackground()
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.lang.Thread.run(Thread.java:856)
09-22 15:45:20.368 E/AndroidRuntime( 3630): Caused by: java.lang.NullPointerException: println needs a message
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at android.util.Log.println_native(Native Method)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at android.util.Log.e(Log.java:231)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExporterAsyncTask.java:113)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExporterAsyncTask.java:48)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-22 15:45:20.368 E/AndroidRuntime( 3630):     ... 5 more
09-22 15:45:20.388 W/ActivityManager(  525):   Force finishing activity org.gnucash.android/.ui.account.AccountsActivity

I guess libcore.icu.ICU.getCurrencySymbol(Native Method) should be working.
I'll update to latest Mi UI and pray for them to fix it...

@nodje nodje closed this as completed Sep 22, 2014
@fefe982
Copy link
Contributor

fefe982 commented Sep 22, 2014

This looks like the stack trace in #191 .

Did you delete all transactions and keep the opening balance before you export?

@nodje
Copy link
Author

nodje commented Sep 22, 2014

sounds like it yes, I remember I've tried that: I've enabled "keep the opening balance" but not delete all transaction.
Why would libcore.icu.ICU.getCurrencySymbol(Native Method) crash? that sounds odd to me

PS: It crashes the same with "Save accounts opening balances" disabled.

@fefe982
Copy link
Contributor

fefe982 commented Sep 22, 2014

null is returned trying to get the currency for the split's account, in SplitsDbAdapter.buildSplitInstance, where the actual error is. NullPointerException is only thrown in the native method.

@nodje
Copy link
Author

nodje commented Sep 22, 2014

It's triggered by SplitsDbAdapter.buildSplitInstance but it crashes in libcore.icu.ICU.getCurrencySymbol(Native Method).
I guess the currencyCode passed as paramter could be faulty.

What are these libcore.icu.ICU APIs? I don't have them available in my IDE.

PS: It's apparently an i18n framework.
@see https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/icu/ICU.java
It either should come from String currencyCode = getCurrencyCode(accountUID); not returning a proper or ICU has a problem on my phone.

I remember I've messed up with the currency of an account for convenience (switched back and force to Double Entry, then later on changed an account currency): it produced a bug once, but has been ok since. Could be related.

@fefe982
Copy link
Contributor

fefe982 commented Sep 22, 2014

I suspect this has the same cause as #191, and should be fixed by #207 .

@codinguser
Copy link
Owner

I concur!

On Mon, Sep 22, 2014 at 11:24 AM, Yongxin Wang notifications@github.com
wrote:

I suspect this has the same cause as #191
#191, and should be
fixed by #207 #207 .


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

@nodje
Copy link
Author

nodje commented Sep 22, 2014

OK, can't make sense of this since I'm not familiar with Gnucash internals but can't wait for it to be fixed ;)
I've got quite a big bunch of Tx to export by now!

@codinguser
Copy link
Owner

Fix will be available in the next version maybe around October. Plan is to enter beta soon.
You could join the beta group if would like faster access to the builds.

Join here: https://plus.google.com/u/0/communities/104728406764752407046
Subscribe herehttps://play.google.com/apps/testing/org.gnucash.android:

@nodje
Copy link
Author

nodje commented Oct 11, 2014

I've updated to version 1.5.1, the export function still crashes, in a cleaner fashion though thanks to @fefe982's fix.
Any chance this would work with the beta channel version?

@codinguser
Copy link
Owner

Does it crash with the same stack trace like before (the currency issue)?

@nodje
Copy link
Author

nodje commented Oct 13, 2014

It does not show a stacktrace anymore as it's become a caught exception.
It display a mall "export OFX file error" while keeping the Exporting Transaction progress window open.

But the system logcat display the same stacktrace as before:

10-13 08:19:18.435 I/ExportDialogFragment( 8008): Commencing async export of transactions
10-13 08:19:18.595 V/org.gnucash.android.db.DatabaseAdapter( 8008): Fetching all accounts from db
10-13 08:19:18.615 V/SplitsDbAdapter( 8008): Fetching all splits for transaction UID b21e9cd469b84fdca9fa52c85fe52fea
..... many many splits..........
10-13 08:19:18.956 V/SplitsDbAdapter( 8008): Fetching all splits for transaction UID bad8ca02938f4e99814b2446aeb05910
10-13 08:19:18.966 W/System.err( 8008): java.lang.NullPointerException
10-13 08:19:18.966 W/System.err( 8008):     at libcore.icu.ICU.getCurrencySymbol(Native Method)
10-13 08:19:18.966 W/System.err( 8008):     at java.util.Currency.<init>(Currency.java:38)
10-13 08:19:18.966 W/System.err( 8008):     at java.util.Currency.getInstance(Currency.java:54)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.model.Money.<init>(Money.java:124)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.SplitsDbAdapter.buildSplitInstance(SplitsDbAdapter.java:141)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.SplitsDbAdapter.getSplitsForTransaction(SplitsDbAdapter.java:273)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.SplitsDbAdapter.getSplitsForTransaction(SplitsDbAdapter.java:289)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.TransactionsDbAdapter.buildTransactionInstance(TransactionsDbAdapter.java:382)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.TransactionsDbAdapter.getAllTransactionsForAccount(TransactionsDbAdapter.java:275)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.AccountsDbAdapter.buildAccountInstance(AccountsDbAdapter.java:383)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.db.AccountsDbAdapter.getAllAccounts(AccountsDbAdapter.java:533)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.export.ofx.OfxExporter.generateExport(OfxExporter.java:107)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.export.ofx.OfxExporter.generateExport(OfxExporter.java:152)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExporterAsyncTask.java:117)
10-13 08:19:18.966 W/System.err( 8008):     at org.gnucash.android.export.ExporterAsyncTask.doInBackground(ExporterAsyncTask.java:52)
10-13 08:19:18.966 W/System.err( 8008):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-13 08:19:18.966 W/System.err( 8008):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-13 08:19:18.966 W/System.err( 8008):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-13 08:19:18.966 W/System.err( 8008):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-13 08:19:18.966 W/System.err( 8008):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-13 08:19:18.966 W/System.err( 8008):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-13 08:19:18.966 W/System.err( 8008):     at java.lang.Thread.run(Thread.java:856)

@codinguser codinguser reopened this Oct 13, 2014
@codinguser
Copy link
Owner

What currencies are you using?

@nodje
Copy link
Author

nodje commented Oct 13, 2014

Mostly CNY and EUR.
FYI I remember having tried to change an account's currency and back, and Gnucash didn't seem to really like it. I can't remember the details unfortunately but it could be related.

@codinguser
Copy link
Owner

@nodje can this issue be closed?
Or are you still experiences issues on 1.5.5?

@nodje
Copy link
Author

nodje commented Apr 1, 2015

I've had to start form scratch and recreate all my accounts to get exports to work again. I guess I won't be able to reproduce this bug ever.

@nodje nodje closed this as completed Apr 1, 2015
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

3 participants