Cannot call method from another Module : Android studio

Viewed 11113

I have two modules in android studio

  1. Standard android app module
  2. domain module

The domain module in been added to both settings.gradle and build.gradle

include ':mobile', ':domain' & compile project(':domain') respectively like this

Inside domain module I have a class like this :

public class DomainUtils {

    Context mContex;
    public DomainUtils(Context context){
        this.mContex = context;
    }
    public  void toast(String string){
        Toast.makeText(mContex, string,Toast.LENGTH_LONG).show();
    }
    public String returnHi(){
        return "hi";
    }
}

But when i try to call new DomainUtils(context).toast("hi");

from a class inside App module :

  1. The method inside DomainUtils does not execute
  2. Program flow does not continue to next line in the calling class ( program flow stops"
  3. I do not see any error logs in logcat.

------------BUT ----------

When I run the method returnHi() It works fine .

3 Answers
Related