0

This is the library I am using. But I need to change the style java code. But since it's an external dependency, the file is read-only.

I learned here that if I add it as module I can then edit the file. I did that. I added the module successfully.

But now, the problem is how do I use the class from the library module. For instance, in my MainActivity.java, when I declared the global variable CarouselPicker carousel, Android Studio said 'Cannot resolve symbol CarouselPicker' and there is no Alt+Enter option to import any class. CarouselPicker is a class in the library. It worked when I used the library using compile in dependencies.

EDIT:

This is my Android file structure:

screenshot of Android file structure

This is the dependencies block code of my build.gradle(Module:app):

screenshot of code bloack

In my Share.java file, I tried to import CarouselPicker, this is what I get for Alt+Enter:

What Alt+Enter gave me.

joe doe
  • 117
  • 9
  • Possible duplicate of [How to import class from another module in android studio?](https://stackoverflow.com/questions/34419962/how-to-import-class-from-another-module-in-android-studio) – Abdulmalek Dery Jun 29 '18 at 20:01

1 Answers1

0

please make sure that you have added the dependency line of the module in the gradle

see this for more details How to import class from another module in android studio?

Abdulmalek Dery
  • 996
  • 2
  • 15
  • 39
  • 1
    I added compile project (':CarouselPicker-master'); in the dependencies of my project. I synced. Then in my class, I wrote import com.example.android.myProject.CarouselPicker-master. It says cannot resolve symbol CarouselPicker. – joe doe Jun 29 '18 at 20:13
  • try to type only `CarouselPicker` then put the cursor on it and hit alt+enter then android studio will automatically put the correct package name – Abdulmalek Dery Jun 29 '18 at 20:18
  • Nope, Alt+Enter doesn't bring up anything. – joe doe Jun 29 '18 at 20:40
  • try to delete the .idea and .gradle folders from your project directory then clean and build the project – Abdulmalek Dery Jun 29 '18 at 21:09
  • now I see what is the problem....you should write `CarouselPicker` inside any function of your class then put the cursor on it ...then hit alt+enter ...then it should work – Abdulmalek Dery Jun 29 '18 at 21:14