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

When I call Crypto.decrypt, it gives me a NullPointerException: println needs a message #5

Closed
jagan999 opened this issue Apr 4, 2017 · 11 comments
Assignees
Labels

Comments

@jagan999
Copy link

jagan999 commented Apr 4, 2017

Can you pl tell me when I get this error? I've verified that the decrypt function is passed a valid string, it is not null

@yakivmospan
Copy link
Owner

Can you please share the full stack trace here ?

@yakivmospan yakivmospan self-assigned this Apr 4, 2017
@yakivmospan
Copy link
Owner

Also you can set an error listener to get more details about exceptions (errors) you got while working with Crypto:

crypto.setErrorListener(new ErrorListener() {
        @Override
        public void onError(Exception e) {
            / / handle error here        
        }
});
        

@jagan999
Copy link
Author

jagan999 commented Apr 4, 2017

Full stack trace here...I've stripped out the detailed package name for confidentiality purposes

                                                            Detailed StackTrace
                                                            java.lang.NullPointerException: println needs a message
                                                                at android.util.Log.println_native(Native Method)
                                                                at android.util.Log.e(Log.java:232)
                                                                at com.yakivmospan.scytale.ErrorHandler.onException(ErrorHandler.java:19)
                                                                at com.yakivmospan.scytale.Crypto.decrypt(Crypto.java:178)
                                                                at com.yakivmospan.scytale.Crypto.decrypt(Crypto.java:139)
                                                                at MySQLiteOpenHelper.getEncryptedDBPassword(MySQLiteOpenHelper.java:109)
                                                                at MySQLiteOpenHelper.<init>(MySQLiteOpenHelper.java:48)
                                                                at Tasks.sync(Tasks.java:563)
                                                                at IntentService.onHandleIntent(IntentService.java:84)
                                                                at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                at android.os.Looper.loop(Looper.java:148)
                                                                at android.os.HandlerThread.run(HandlerThread.java:61)

@yakivmospan
Copy link
Owner

It is crashing on passing an empty exception message to the ErrorHandle. This is an internal error. But you still have some issues on your code cause ErrorHandle is triggered.

Thanks for reporting this. I will fix it and update here ASAP.

@yakivmospan yakivmospan added the bug label Apr 4, 2017
@jagan999
Copy link
Author

jagan999 commented Apr 4, 2017

ok, thanks. I tried to add an error listener but it didn't even get triggered.

@yakivmospan
Copy link
Owner

Yup cause an issue is rised before, on line number 19, and listener is triggerd after.
Anyway as I told you, you got some issues with crypto setup, error handler is triggered only if an exception was thrown during encryption.

https://github.com/yakivmospan/scytale/blob/master/library/src/main/java/com/yakivmospan/scytale/ErrorHandler.java#L19

@yakivmospan
Copy link
Owner

yakivmospan commented Apr 4, 2017

I've just released new version, please try it :

compile 'com.yakivmospan:scytale:1.0.1'

@jagan999
Copy link
Author

jagan999 commented Apr 4, 2017

Thanks. Works now. After analysis, I discovered that I was decrypting a string using a different key than that used for encrypt. However, the error thrown was very misleading. Maybe, this is fixed with your new build now. I don't see this error now since I've fixed my code.

@yakivmospan
Copy link
Owner

Can you please revert changes and try it with new build ? It would be very helpful to analyze if new build can provide your more details about an error an stop crashing. Thanks

@jagan999
Copy link
Author

jagan999 commented Apr 5, 2017

I want to try and help but I've made too many changes since I reported the issue to roll back and test again. I'll keep you posted if I find any improvement in error logging. BTW, your wrong error never crashed my app, it only threw a confusing error message. Also, your library rocks...great job on that. It simplified my job a whole lot. Thanks for this.

@yakivmospan
Copy link
Owner

Glad that Scytale helped you and thanks for reporting this issue. Closing it.

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

No branches or pull requests

2 participants