0
 import org.spongycastle.jce.provider.BouncyCastleProvider;
   Security.addProvider(new BouncyCastleProvider());
                    KeyFactory factory = KeyFactory.getInstance("ESDSA", "BC");
                    publicKeyServer = (ECPublicKey) factory.generatePublic(new X509EncodedKeySpec(bytePubKeyServer));

This is the code I try to add the bounycastleProvider. The bouncycastle Jar don't work on Android so I saw that I need to use the spongy castle jar. So I have added the spongy castle jar now I am stuck. In this code I try to convert bytes to a public key.

This is the error message

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/spongycastle/util/Strings
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.3"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        implementation 'com.madgag.spongycastle:bctls-jdk15on:1.58.0.0'
    }


}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Noah Schmidt
  • 26
  • 1
  • 7
  • Have you added Spongycacstle in your Gradle configuration as library? Please edit your question and add the line where you add Spongycastle in gradle. – Robert Apr 25 '21 at 11:33
  • Yeah I have added my gradle build script – Noah Schmidt Apr 25 '21 at 11:46
  • 1
    As there is not Spongycastle entry you have place the JAR fil in the `libs` folder? Don't do that, just add Spongycastle as gradle dependency: https://stackoverflow.com/a/66323575/150978 Spongycastle library will then be automatically downloaded and added to your project. Delete the jar file in the libs folder. – Robert Apr 25 '21 at 12:30
  • But it dont' work i have updated the build.gradle – Noah Schmidt Apr 25 '21 at 13:38
  • 1
    You have added the dependencies to the buildscript section of your project. Instead you have to add it to the dependencies section of the gradle config of your app. Please learn the basics of Android Studio/Gradle: https://developer.android.com/studio/build/dependencies – Robert Apr 25 '21 at 14:06

0 Answers0