Consuming aars from eclipse does not work

自古美人都是妖i 提交于 2019-12-23 04:28:29

问题


*THIS PART WAS MY ORIGINAL STARTING PROBLEM. PLEASE READ THE UPDATES
I have imported an android project in eclipse that apparently depends on rengwuxian.
Since I could not find the jar and did not know how else to do it, I followed the instructions in consuming-aars-eclipse and imported a second project with the artifacts from the aar as an android eclipse project as well.

Then in my original project that I got compilation errors for com.rengwuxian.materialedittext.MaterialEditText in my layout files I added this newly created from the aar project as a reference (Project->Properties->Build Path->Add Project)

The compilation errors got resolved! But in my layout files now everywhere that is defined the element com.rengwuxian.materialedittext.MaterialEditText I get errors in the resource definitions.

Eg.the following:

error: No resource identifier found for attribute 'baseColor' in package 'com.test

The attibute it seems to complaint about is:

<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"

This @color/text_color is defined in my original application in the original application's package and apparently the classes in the aar imported project (com.rengwuxian.materialedittext.MaterialEditText) can not see/access these resources.

How can I fix this? Or is there another better way for my problem?

Note: I also tried adding a source link to the folder of my project's res/ folder but did not solve this.

Update:
I removed the reference to the project and add the classes.jar to the build path (this jar was inside the aar project). Same issue

UPDATE 2:
I found this that helps to import aars to eclipse aar-for-eclipse. I copy/pasted the code snippets (task copyJarDependencies etc) in the folder but I got an exception:

No such property: libDir for class: org.gradle.api.tasks.Copy_Decorated

So I added a def in the line `libDir = new File(project.projectDir, '/libs') Then this worked but I got:

Could not find property 'compile' on configuration container

How can fix this? I am not sure what to declare or what is missing

Update 3:
I added apply plugin: 'java' and the compile attribute is ok now but I get:

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

How can I fix this so that it works?
I am using this project ---> https://github.com/rengwuxian/MaterialEditText
And this post ---> http://www.nodeclipse.org/projects/gradle/android/aar-for-Eclipse


回答1:


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 )



来源:https://stackoverflow.com/questions/28780426/consuming-aars-from-eclipse-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!