今天在使用gradle打包的时候,自定义控件的命名空间,使用的是
xmlns:library="http://schemas.android.com/apk/res/包名"
gradle在build的时候,发现报错;
后来查了查res与res-auto的区别;
通常我们在布局文件中使用自定义属性的时候
会这样写
xmlns:app="http://schemas.android.com/apk/res/包路径"
但如果你当前工程是做为lib使用,那么你如上所写 ,会出现找不到自定义属性的错误 。
这时候你就必须 写成
xmlns:app="http://schemas.android.com/apk/res-auto/包路径"
如果工程不是已library工程存在,那么即使使用xmlns:app="http://schemas.android.com/apk/res-auto/包路径"也不会出错;
所以建议使用res-auto;