【问题标题】:Consuming aars from eclipse does not work从 Eclipse 中消耗 aars 不起作用
【发布时间】:2015-02-28 09:57:45
【问题描述】:

*这部分是我最初的开始问题。请阅读更新
我在 Eclipse 中导入了一个显然依赖于 rengwuxian 的 android 项目。
由于我找不到 jar 并且不知道该怎么做,所以我按照consuming-aars-eclipse 中的说明操作,并从 aar 导入了第二个项目作为 android eclipse 项目。

然后在我的原始项目中,我在布局文件中遇到了 com.rengwuxian.materialedittext.MaterialEditText 的编译错误,我添加了从 aar 项目中新创建的这个作为参考(项目->属性->构建路径->添加项目)

编译错误已解决! 但是现在在我的布局文件中定义元素 com.rengwuxian.materialedittext.MaterialEditText 的任何地方我都在资源定义中遇到错误。

例如:

错误:在中未找到属性“baseColor”的资源标识符 包'com.test

它似乎抱怨的态度是:

<com.rengwuxian.materialedittext.MaterialEditText
            android:id="@+id/client"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            .....
            android:textColor="@color/text_color"
            app:baseColor="@color/text_color"
            app:primaryColor="@color/text_color" />

---> app:baseColor="@color/text_color"

这个@color/text_color 是在原始应用程序包中的原始应用程序中定义的,显然aar 导入项目(com.rengwuxian.materialedittext.MaterialEditText)中的类无法查看/访问这些资源。

我该如何解决这个问题?还是有另一种更好的方法来解决我的问题?

注意:我还尝试将源链接添加到我项目的 res/ 文件夹的文件夹中,但没有解决这个问题。

更新:
我删除了对项目的引用并将 classes.jar 添加到构建路径(这个 jar 在 aar 项目中)。同样的问题

更新 2:
我发现这有助于将 aars 导入 eclipse aar-for-eclipse。我在文件夹中复制/粘贴了代码 sn-ps(任务 copyJarDependencies 等),但出现异常:

没有这样的属性:libDir 类:org.gradle.api.tasks.Copy_Decorated

所以我在 `libDir = new File(project.projectDir, '/libs') 行中添加了一个 def 然后这有效,但我得到了:

在配置容器上找不到属性“编译”

如何解决这个问题?我不确定要申报什么或缺少什么

更新 3:
我添加了apply plugin: 'java',编译属性现在还可以,但我得到了:

configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each { 文件文件 -> moveJarIntoLibs(file)}

如何解决此问题以使其正常工作?
我正在使用这个项目 ---> https://github.com/rengwuxian/MaterialEditText
还有这个帖子--->http://www.nodeclipse.org/projects/gradle/android/aar-for-Eclipse

【问题讨论】:

  • 改用android:baseColor
  • @Apurva:现在我得到同样的错误,但包'android'
  • @Apurva:请查看更新

标签: java android eclipse adt aar


【解决方案1】:

我在 gradle 上遇到了类似的问题,但在 android studio 上。我的解决方案是使用

configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each {moveJarIntoLibs(it)}

代替:

configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each { File file -&gt; moveJarIntoLibs(file)}

记住不要在同一个项目中应用 java 和 android 插件,因为它不会工作(参见 gradle 和 --debug --stacktrace )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-04
    • 2013-05-31
    • 2022-01-15
    • 1970-01-01
    • 2012-06-24
    • 2019-07-18
    • 1970-01-01
    • 2018-11-11
    相关资源
    最近更新 更多