不能在其他项目中使用自定义视图(aar lib)

cannot use custom view(aar lib) in other project

我有一个 aar 文件(我制作的),我想用于另一个项目的应用程序模块。

aar 有一些自定义视图

我正在使用 android 工作室


1.Problem

1) CustomViewLibrary 项目

2) 在其他 SomethingApp 项目中


2.Result


我试过重建,清除但它不起作用..

预期的问题是自定义视图 aar 访问奇怪上下文的资源。 (自定义视图访问颜色和上下文中的其他颜色(CustomViewLibrary 的资源))

对不起我的英语..

我该如何解决这个问题?请帮助我


编辑

in other somthingApp, i want to use my aar to this somthingApp project

the my aar source line when i get NPE, it use aar's resource(in this case colors.xml) from somthingApp's context

解决了

之前

import aar to android studio's menu(File > New > Import Projects > Module ...)

之后

将这些行应用于应用程序的构建 gradle

repositories {
  jcenter()
  flatDir {
    dirs 'libs'
  }
}
compile(name: 'CustomViewLibrary', ext: 'aar')

现在可以在 xml 编辑器和 运行

中成功渲染