在集成Tron-java Sdk后运行发现总是异常
java.lang.ExceptionInInitializerError
...
...
java.security.NoSuchAlgorithmException: no such algorithm: ECDSA for provider BC
解决办法:
1.在application的onCreate里面加入下面的方法
public void setupBouncyCastle() {
final Provider provider = Security.getProvider(BouncyCastleProvider.PROVIDER_NAME);
if (provider == null) {
// Web3j will set up the provider lazily when it's first used.
return;
}
if (provider.getClass().equals(BouncyCastleProvider.class)) {
// BC with same package name, shouldn't happen in real life.
return;
}
// Android registers its own BC provider. As it might be outdated and might not include
// all needed ciphers, we substitute it with a known BC bundled in the app.
// Android's BC has its package rewritten to "com.android.org.bouncycastle" and because
// of that it's possible to have another BC implementation loaded in VM.
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
Security.insertProviderAt(new BouncyCastleProvider(), 1);
}
2.在AndroidMainfest.xml中添加代码:
<application
......
android:hardwareAccelerated="true"
android:largeHeap="true"
...... >
此时运行就正常了。