异常信息:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jxstnu_helper.dev/com.baidu.android.pushservice.richmedia.MediaListActivity}: android.content.res.Resources$NotFoundException: File res/layout/bpush_media_list.xml from xml type layout resource ID #0x7f03000a
错误原因分析:
我在Gradle配置了以下信息,移除了没有使用的资源文件,从而造成一些第三方的SDK找不到资源文件。
引起错误的配置信息:
release {
//Ziplign优化
zipAlignEnabled true
//移除无用的资源文件
shrinkResources true
//混淆
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
解决方法:
1.在我们的代码中任意文职添加如下代码,把被优化的资源文件给加进去
this.getResources().getLayout(R.layout.bpush_media_list_item);
2.关闭移除资源文件的优化选项