Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imported module in Android Studio can't find imported class

I recently downloaded the ViewPagerIndicator library and imported it into android studio. After adding it to my project I get a rendering error "The following classes could not be found:" and points to com.viewpagerindicator.IconPageIndicator.

The steps I took were Files->Import Module->'library name', Project Structure -> Dependencies -> + the imported module. Then to my layout xml file I added the <com.viewpagerindicator.IconPageIndicator />, after that I got the missing class problem.

It compiles just fine and I went through all of the build.gradle and settings.gradle files and compared them to what they should be online.

MyApp->build.gradle has compile project(':library') under dependencies settings.gradle has include ':library' with no build errors.

like image 670
user1971 Avatar asked Aug 24 '14 22:08

user1971


People also ask

Where are modules Android Studio?

Click File > New > New Module. In the Create New Module window that appears, Android Studio offers the following device modules: Phone & Tablet Module.

How do I import a module into gradle?

In Android Studio, Right-clicking on the folder to add as library. Editing the dependencies in the build. gradle file, adding: compile fileTree(dir: 'libs', include: '*. jar')}


Video Answer


2 Answers

First of all, you must import your library project by following that path:

File --> New --> Import Module 

After you have imported the library project successfully, you must check your build.gradle file inside your project's folder if the following line is present at the "dependencies" section:

implementation project(':NameOfTheLibProject') 

Then your project must be built successfully.

like image 156
Bahadir Tasdemir Avatar answered Sep 28 '22 02:09

Bahadir Tasdemir


I found that my issue was the Android Plugin Version under Project Structure --> Project was different to the version my plugins all used. Once I aligned them to the same version, I could see all my classes from my imported module.

Took me hours :(

like image 32
Quintin Balsdon Avatar answered Sep 28 '22 04:09

Quintin Balsdon