Android Studio 中的导入模块找不到导入的类 [英] Imported module in Android Studio can't find imported class

查看:149
本文介绍了Android Studio 中的导入模块找不到导入的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载了 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'项目结构->依赖关系 ->+ 导入的模块.然后在我的布局 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.gradledependencies 下有 compile project(':library')settings.gradleinclude ':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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆