Android AAR Manifrest文件theme冲突问题

作者: NicUniverse | 来源:发表于2017-11-16 14:06 被阅读262次

当我们引入aar作为项目的依赖时,由于aar一般包含资源文件,导致androidManifest清单文件需要合并。一般来说,编译之前我们需要在项目的gradle文件中,加上:

    <application 
    .....
    android:theme="@style/newTheme"
    tools:replace="android:theme">

同时还需要保证aar的androidManifest清单文件里面没有上面这句话。这句话的作用是用项目的theme代替aar中的主题。一般的,项目使用"@stlye/AppTheme",不会有问题,但是如果在aar中自定义了主题,运行是就会发生布局文件就会出现InflateException,这是由于自定义的theme文件被合并导致自定义的attr无法找到。
在android studio的user guide中发现,其实theme可以单独定义在每个activity的声明中,如

<activity android:name=”com.example.ActivityOne”
android:theme=”@oldtheme” />

这样将即可解决清单文件合并时,theme被覆盖的问题。

相关文章

网友评论

    本文标题:Android AAR Manifrest文件theme冲突问题

    本文链接:https://www.haomeiwen.com/subject/ryulvxtx.html