I created two modules in single android project, named it x and y.
Now I want to import class Foo in the class Egg, for which I wrote the statement mentioned below in class Egg
Import com.example.y.Foo;
Now, Foo is not recognized by android.
Questions,
Is it possible to import Class from a different module using just import statement?
Do I need to create library of Module y and then import created library into module x?
Or may the solution is something else.
These modules allow you to store source code and Android resources which can be shared between several other Android projects. To use a Java library (JAR file) inside your Android project, you can simple copy the JAR file into the folder called libs in your application.
Make sure of the following:
In settings.gradle, you should have: include ':x', ':y'
.
In x/build.gradle, you should add y as a dependency:
dependencies { compile project(':y') // other dependencies }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With