I'm trying to use web3j + Infura to interact with the Rinkeby chain from an android app. I first wrote a simple test in Java and everything worked - transactions, interacting with contracts, you name it. So I moved to Android, but in the emulator loading the credentials from file is taking forever + showing several garbage collection warnings, and on my Moto G5plus phone is actually crashing due to an OutOfMemoryError. This is what I am doing (in an AsyncTask):

Credentials credentials = WalletUtils.loadCredentials("notMyActualPassword", cacheFilePath);

The file path is correct, I do print the wallet file in my logs and it shows up correctly. The crash logs were copied into this gist.

Does anyone know why this might happen?


I got this , I think there is a C implement of Scrypt lib that you need add the .so file to your app dictionary,place in your apk file's lib/armeabi dictionary and it will automatically loaded.This maybe helpful,I have solved this problem through use C implement instead of default java implement https://github.com/wg/scrypt/tree/master/src/android/resources/lib/arm5 Here is the compiled libscrypt.so file.

  • Thanks, that should help, but it's giving me a java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com....myapplication-1/lib/arm/libscrypt.so: has text relocations error. Any idea why?
    – manuhalo
    Aug 2 '17 at 11:54

https://github.com/web3j/web3j/issues/511 This github issue looks very similar to your question. If you scroll down to weixuefeng's reply, some solution is provided. (But the link is in Chinese)

And also, due to my newly created account limitation... I cannot comment on the answer of the 樊晋龙. If .so file has solved your problem, can you explain more about it?

  • Sorry, this is a side project that I stopped working on ages ago. I vaguely remember that I could get it to work simply by increasing the memory limits of my test app - it was an academic exercise so it didn't matter too much. But honestly it has been so long that I would not trust my memory, and besides hopefully someone has found a proper fix. Good luck!
    – manuhalo
    Nov 5 '18 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.