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

本文详细介绍了在Android开发中遇到布局库导入失败及资源冲突问题的解决方法,通过调整项目配置和引入用户库的方式,最终成功运行项目并避免资源冲突。

今天导入一个项目,发现运行不能,红叉叉表示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库指向新路径。

运行,成功!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值