android - Intellij IDEA 项目中不能包含源库

标签 android intellij-idea library-project

我在 IDEA 中使用通用助手 创建了库项目,我在我的 android 应用程序中使用了它。

然后我创建了 android 应用程序并将我的库项目包含在其中,如 this tutorial said .

一切似乎都很好,代码自动完成工作正常,IDEA 识别该库以及其中的所有类和方法。

但后来我编译应用程序并看到错误“‘org.my.helperlibrary’不存在”。然而,正如我所说,在制作/启动项目之前,IDEA 表现得一切正常。

Here is similar question ,但答案很简单,当然我的图书馆已经检查了“是图书馆项目”选项,但我仍然无法启动使用我的图书馆的应用程序。

更新:

我刚刚看到一个错误:“UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/my/helperlibrary/Helper;”当我删除了库的所有用法时在我的安卓应用程序中。所以它只是包含在我的应用程序中,并没有被使用。

最佳答案

原来我不应该在那个窗口手动添加依赖

enter image description here

我宁愿在左侧的项目窗口中添加新模块

enter image description here enter image description here enter image description here

然后我应该在我想使用的android库项目的根文件夹中选择iml文件

enter image description here

然后我按下完成,从那时起我的项目中就有了两个模块

enter image description here

之后,当使用类时,我可以在 SampleLibrary 中的任何类上按 Alt+Enter 并告诉 IDEA 添加模块依赖性

enter image description here

然后我发现 IDEA 可以在没有我的情况下满足我的所有需求。我现在可以使用 SampleApplication 中的 SampleLibrary!

enter image description here

关于android - Intellij IDEA 项目中不能包含源库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13064602/

相关文章:

android - 可穿戴数据层 API : Can't find setUrgent() method in putDataMapRequest

version-control - Intellij IDEA 红色/棕色突出显示的文件名

android - 基于 Activity 的应用程序可以没有 Activity 吗?

android - 在 Android 项目 :- In my application there are lots of images, 中,我必须验证它们,我如何使用断言

java - Android:抽屉导航布局动态更改图标

android - Google 云端硬盘 SDK 客户端 ID

java - IntelliJ 线程调试

ubuntu - 升级 intellij 2018 -> 2019 的最简单方法?

android - 选中 "is Library"复选框有什么作用 "Under the Cover"?

android - 如何将库项目转换为jar