Android Studio中的导入模块找不到导入的类 [英] Imported module in Android Studio can't find imported class
问题描述
我最近下载了 ViewPagerIndicator库,并将其导入了android studio.将其添加到项目中后,出现渲染错误找不到以下类:",并指向com.viewpagerindicator.IconPageIndicator.
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.
我采取的步骤是Files->Import Module->'library name'
,Project Structure -> Dependencies -> + the imported module
.然后在我的布局xml文件中添加了<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.
它可以正常编译,我遍历了所有build.gradle和settings.gradle文件,并将它们与应该在线的文件进行了比较.
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
在dependencies
下具有compile project(':library')
settings.gradle
的include ':library'
没有构建错误.
MyApp->build.gradle
has compile project(':library')
under dependencies
settings.gradle
has include ':library'
with no build errors.
推荐答案
首先,必须通过以下路径导入库项目:
First of all, you must import your library project by following that path:
File --> New --> Import Module
成功导入库项目后,如果依赖项"部分中存在以下行,则必须检查项目文件夹中的build.gradle文件:
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.
这篇关于Android Studio中的导入模块找不到导入的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!