Home » Java » java – NoSuchMethodError Exception in Android-Exceptionshub

java – NoSuchMethodError Exception in Android-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’m trying to integrate a jar which is build using some other module(lets say ‘Module A’ with version 1.0) using compileOnly and while integrating with an Android Application but with different version of Module A version 1.2, I’m getting

java.lang.NoSuchMethodError: No static method init(Landroid/content/Context; )V in class Lcom/dexter/lib/MyLib; or its super classes (declaration of ‘com.dexter.lib.MyLib’)

Difference between 1.0 and 1.2 version of Module A:

In version 1.0

class MyLib{
   public static void init(Context context) {
       // some init stuff
   }
}

In version 1.2

class MyLib{
   public static String init(Context context) {
       // some init stuff
        return "Success";
   }
}

Using

MyLib.init(this);

Ideally it should work, but I’m not able to understand why it is crashing.

How to&Answers: