Imported module in Android Studio can't find i

2019-03-14 07:26发布

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.

6条回答
疯言疯语
2楼-- · 2019-03-14 08:08

I had the same problem. I just did: Invalidate / Restart ..

查看更多
你好瞎i
3楼-- · 2019-03-14 08:09

I too had trouble importing module as it was not appearing in list of modules. And way it worked for me is manually entering it in settings.gradle this way:

include ':app', 'module_name'

And in build.gradle

compile project(':module_name')
查看更多
ら.Afraid
4楼-- · 2019-03-14 08:11

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.

查看更多
成全新的幸福
5楼-- · 2019-03-14 08:14

The following solution worked for me,just two steps.

Go to your project structure on android studio, select project from left side.Change Android plugin version to Gradle version press ok.

If error occurs after synchronization again go to project structure and select project.undo the android plugin version like before.Gradle will align the library and make the class visible to XML files.

查看更多
老娘就宠你
6楼-- · 2019-03-14 08:29

In my case, I did add in app gradle:

compile project(':NameOfTheLibProject')
// or
implementation project(':NameOfTheLibProject')

but it only works when I change

compileSdkVersion 
minSdkVersion 
targetSdkVersion 

in app and the other modules are the same.

查看更多
贪生不怕死
7楼-- · 2019-03-14 08:30

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 :(

查看更多
登录 后发表回答