android studio3.0(二)Cannot set the value of read-only property 'outputFile'
2017-11-01 13:53
786 查看
接着说android studio3.0更新以后个人在使用的过程中遇到的坑,大多数还是因为Gradle插件的升级导致一些配置的改变。
像以往一样,在gradle中配置打包apk时的输出路径和apk的名字,配置语句样例:
图1
![](http://img.blog.csdn.net/20171101142123351?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGRlcl9UYW9nZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
图2
![](http://img.blog.csdn.net/20171101141455131?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGRlcl9UYW9nZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
但是不同以往的是之前没有问题的配置语句现在用起来却遇到了问题:
图3
![](http://img.blog.csdn.net/20171101140323722?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGRlcl9UYW9nZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
在Stack Overflow上得到答案:
https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
然后在android developer官网android studio3.0的使用说明处找到同样的答案:
图4
![](http://img.blog.csdn.net/20171101142623598?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGRlcl9UYW9nZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
请自行翻译吧,我感觉主要在说gradle3.0的api变化了,对outputFile对象的访问在某些情况下不再适用了,但是将each改为all的话,像编译apk名字这种"简单的task"还是可用的。
于是将图1中的配置语句改为:
图5
![](http://img.blog.csdn.net/20171101142941159?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGRlcl9UYW9nZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
重新sync后编译通过。
说明:
①上面的配置默认apk的输出路径是app/build/outputs/flavorName/release(或者debug),可自行更改成任意自己想要的路径,比如:
图6
![](http://img.blog.csdn.net/20171101144308660?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGRlcl9UYW9nZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
②outputFileName是配置all的情况下的全局属性(?),可以直接使用。但如果是在each条件下,则没有这个属性;
③在图1中用的是output.outputFile = new File(...,...),经过自测,3.0以后即使将上述的each改为all以后还是不能给它重新赋值,它是read-only的,只能用outputFileName这个属性。
像以往一样,在gradle中配置打包apk时的输出路径和apk的名字,配置语句样例:
图1
图2
但是不同以往的是之前没有问题的配置语句现在用起来却遇到了问题:
图3
在Stack Overflow上得到答案:
https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
然后在android developer官网android studio3.0的使用说明处找到同样的答案:
图4
请自行翻译吧,我感觉主要在说gradle3.0的api变化了,对outputFile对象的访问在某些情况下不再适用了,但是将each改为all的话,像编译apk名字这种"简单的task"还是可用的。
于是将图1中的配置语句改为:
图5
重新sync后编译通过。
说明:
①上面的配置默认apk的输出路径是app/build/outputs/flavorName/release(或者debug),可自行更改成任意自己想要的路径,比如:
图6
②outputFileName是配置all的情况下的全局属性(?),可以直接使用。但如果是在each条件下,则没有这个属性;
③在图1中用的是output.outputFile = new File(...,...),经过自测,3.0以后即使将上述的each改为all以后还是不能给它重新赋值,它是read-only的,只能用outputFileName这个属性。
相关文章推荐
- Cannot set the value of read-only property 'outputFile'
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Android Gradle 3.0.0-alpha2 plugin, Cannot set the value of read-only property 'outputFile'
- Error:(45, 0) Cannot set the value of read-only property 'outputFile' for ...
- android studio3.0 编译 Cannot set the value of read-only property 'outputFile' for apkVariantOutputImp
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- Error:Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apk
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- “Cannot set the value of read-only property 'outputFile' for 。。。”解决
- Cannot set the value of read-only property 'outputFile'
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=M
- Android Studio3.0报错:Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Can not set the value of read-only property 'jniFolders' for task ': android: packageDebug