[英]how to fix 'no such algorithm ecdsa for provider bc' while creating new wallet file using web3j
I am doing this on the latest version of the android studio and minimum SDK version is 15 dependencies:我在最新版本的 android studio 上执行此操作,最低 SDK 版本为 15 个依赖项:
> implementation fileTree(dir: 'libs', include: ['*.jar'])
> implementation 'com.android.support:appcompat-v7:28.0.0'
> implementation 'com.android.support.constraint:constraintlayout:1.1.3'
> testImplementation 'junit:junit:4.12' androidTestImplementation
> 'com.android.support.test:runner:1.0.2' androidTestImplementation
> 'com.android.support.test.espresso:espresso-core:3.0.2' implementation
> 'org.web3j:core:4.2.0-android' implementation
> 'com.android.support:multidex:1.0.3' implementation
> 'com.squareup.okhttp3:okhttp:3.14.0' implementation
> "io.reactivex.rxjava2:rxjava:2.2.2"
My code is:我的代码是:
public String createWallet() throws Exception {
String path = Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS).getPath().toString();
String fileName = WalletUtils.generateNewWalletFile("password", new File(path));
return path + fileName;
}
@serso gives a function "setupBouncyCastle()" that you have to put in your class and call it in onCreat. @serso 提供了一个函数“setupBouncyCastle()”,您必须将其放入类中并在 onCreat 中调用它。 this replace the Android version of Bouncy Castle with the shipped one!这替换了 Android 版本的充气城堡! like he said.就像他说的。 ^^ ^^
If you are preparing release build with minifyEnabled is true and facing this exception:如果您正在准备发布版本, minifyEnabled 为 true 并面临此异常:
java.security.NoSuchAlgorithmException: no such algorithm: ECDSA for provider BC
Add these lines to pro-gurd将这些行添加到 pro-gurd
-dontwarn java8.util.**
-dontwarn jnr.posix.**
-dontwarn com.kenai.**
#-keep class org.bouncycastle.**
-dontwarn org.bouncycastle.jce.provider.X509LDAPCertStoreSpi
-dontwarn org.bouncycastle.x509.util.LDAPStoreHelper
-keepclassmembers class org.web3j.protocol.** { *; }
-keepclassmembers class org.web3j.crypto.* { *; }
-keep class * extends org.web3j.abi.TypeReference
-keep class * extends org.web3j.abi.datatypes.Type
#-dontwarn java.lang.SafeVarargs
-dontwarn org.slf4j.**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.