0

*这部分是我最初的问题。请阅读更新
我已经在 Eclipse 中导入了一个显然依赖于renwuxian的 android 项目。
由于我找不到 jar 并且不知道该怎么做,所以我按照使用 aars-eclipse中的说明并导入了第二个项目,其中包含来自 aar 的工件作为 android eclipse 项目。

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

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

例如以下:

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

它似乎抱怨的态度是:

<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。我在文件夹中复制/粘贴了代码片段(任务 copyJarDependencies 等),但出现异常:

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

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

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

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

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

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

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

4

1 回答 1

0

I've got a similar problem with gradle but on android studio. Solution for me was to use

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

instead of:

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

And remember not to apply java and android plugin in the same project, because it won't work (see gradle with --debug --stacktrace )

于 2015-03-30T16:13:48.097 回答