generateBip39Wallet

hi
when i wanna create wallet with generateBip39Wallet function my app is crashed
i must create wallet with this function
my app works on android 9 but it crashes on android 7
please tell me a solution or fix it

my code :

    val dirPath = AndroidApplication.context.getFilesDir().getAbsolutePath()
                val file = File(dirPath)
                val seedWords = WalletUtils.generateBip39Wallet("", file).mnemonic

log cat :

   java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/format/DateTimeFormatter;
        at org.web3j.crypto.WalletUtils.getWalletFileName(WalletUtils.java:177)
        at org.web3j.crypto.WalletUtils.generateWalletFile(WalletUtils.java:86)
        at org.web3j.crypto.WalletUtils.generateBip39Wallet(WalletUtils.java:117)
2 Likes

Hey the reason your android app crashes is because the DateTimeFormatter class was added in api level 26 as shown here i the docs: https://developer.android.com/reference/java/time/format/DateTimeFormatter
Api level 26 was released in Android 8 as shown here: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels

1 Like

how can i fix it?
in version 4.5.12 this method (generateBip39Wallet ) throws null pointer exception :man_facepalming:

Hi Hamid, to fix it you’ll need to change the API level of your Android project to support that method, you’d need API level 26 as mentioned by @Alexandrou.

@hamid_b could you provide your stack trace

hi
i solve it by web3j android
but i see another bug

add RemoteFunctionCall to web3j for android

when i compile solidity with web3j and add smart contract to my project, it cant find RemoteFunctionCall, i forced add this class to my project manually.

org.web3j:core:4.2.0-android

Hey can you share a minimal example of what you are trying to do on GitHub please.