android Eclipse导入com.android.internal.R和layoutlib.jar报错解决方案

来源:互联网 发布:org.apache.httpjar包 编辑:程序博客网 时间:2024/05/17 20:24

今天导入一个项目,发现运行不能,红叉叉表示com.android.internal.R.的一系列引用都失败。

查了一下,这些都在一个SDK自带包layoutlib.jar中。SDK路径\platforms\api版本\data 下就有 layoutlib.jar

 

直接把这些扔到libs文件夹中,红叉叉消失,运行又报错:Conversion to Dalvik format failed with error 1


上网查了一下,大概意思是包中资源与项目资源引用冲突,于是继续查。


果然不负有心人,应该采用用户库的形式导入该库,具体步骤如下:

1. Right-click the project in Eclipse and select "Build Path -> Add Libraries...".
2. Select User Library from the list and click Next.
3. Click the "User Libraries..." button.
4. Click "New..." in the User Libraries dialog.
5. Give the user library a name and select the System library checkbox and click OK.
6. Highlight the newly added user library in the list and click the "Add JARs..." button and add the desired jar files.
7. Click OK on the User Libraries dialog.
8. Make sure the new user library is checked in the Add Library dialog and click finish.


按照上面的步骤,我命名库Layoutlib,再运行,还是报错。

仔细看了下项目中库jar包支持,发现自己的Layoutlib和系统的Android Private Libraries都引用了layoutlib.jar


layoutlib.jar从libs中拿出来放到应用根目录,把Layoutlib库指向新路径。

运行,成功!



0 0
原创粉丝点击