packageOfficialDebug和resourceFile does not exist.

来源:互联网 发布:软件项目任务书 编辑:程序博客网 时间:2024/06/11 16:40

原文地址:http://www.jianshu.com/p/b7cdff7fe6e1

Android Studio运行时候报packageOfficialDebug错误

报错信息为

Error:A problem was found with the configuration of task':watch:packageOfficialDebug'.
File '...\build\intermediates\res\resources-official-debug-stripped.ap_' specified for property 'resourceFile' does not exist.

解决方法一:

这个大多数原因是开启了混淆造成的,关闭Debug模式下的混淆开关后重新编译即可,代码如下:

buildTypes {        release {            buildConfigField("boolean", "LOG_DEBUG", "false")            minifyEnabled true            shrinkResources true            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }        debug {            minifyEnabled false            shrinkResources false            buildConfigField("boolean", "LOG_DEBUG", "true")            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }

minifyEnabled即以前的runProguard,用来控制是否混淆。

shrinkResources为true时自动去掉多余资源。

注:Gradle2.0以上的版本minifyEnabled字段为true时已经包含了shrinkResources,在代码优化时会自动去掉多余资源,所以在打正式包时也不需要设置shrinkResources字段。

解决方法二:

Android Studio2.0以上有了Instant Run功能,很多情况下运行报错都跟Instant Run有关
进入File --> Setting(Ctrl+Alt+S)找到InstantRun功能,把InstantRun功能关闭


image

 


阅读全文
0 0
原创粉丝点击