美文网首页程序猿
浅谈Android Stduio升级3.0,Gradle升级4.

浅谈Android Stduio升级3.0,Gradle升级4.

作者: 刘阿火 | 来源:发表于2017-10-30 17:09 被阅读318次

    ___前两天盼望已久的as3.0终于推送了正式版,收到更新通知后随手就给更新了,一些编译的问题也正在悄然走来。。。
    ___No1:Error:(56, 0) Cannot set the value of read-only property
    'outputFile' for ApkVariantOutputImpl_Decorated,首先报的就是配置自定义apk配置出错
    根据提示得到现在要的是名字不是文件了,所以直接按下图修改即可

    error1.png
    ___No2:Error:Cannot choose between the following configurations of project :pickerview:
    -debugApiElements
    -debugRuntimeElements
    -releaseApiElements
    -releaseRuntimeElements
    All of them match the consumer attributes: ...
    看提示不容易发现问题,搜了一下相关文章发现是apt的锅,由于apt作者不再维护,google就发部了annotationProcessor ,再我们项目里面呢也正好有butterknife,还有eventbus,这个时候呢改一下apt的相关配置了,首先删掉根项目build.gradle里面的 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8';然后去app里面的build.gradle,去掉apply plugin: 'android-apt',依赖改成annotationProcessor "com.jakewharton:butterknife-compiler:**"
    defaultConfig下添加
    javaCompileOptions {
    annotationProcessorOptions {
    includeCompileClasspath = true
    }
    }

    如果有设置eventbus加速模式的把
    apt {
    arguments {
    eventBusIndex "com..MyEventBusIndex"
    }
    }
    删掉
    然后到defaultConfig下添加
    javaCompileOptions {
    annotationProcessorOptions {
    includeCompileClasspath = true
    arguments = [eventBusIndex: 'com.kk.user.KKEventBusIndex']
    }
    }
    同样把依赖apt改成annotationProcessor如果还有别的apt依赖自行搜索两者的使用规则。
    ___No3:Error:Cause: getMainOutputFile is no longer supported. Use getOutputFileName if you need to determine the file name of the output.
    这个问题就很奇怪了,翻译了一下也看不出来啥玩意,百度搜也搜不准,恰巧开大会vpn又不让用,后来勉强在stack上发现解决方案就是在android:下添加flavorDimensions "default"具体这个东西是干啥的,暂时还没去了解,加上后就接着发下了下一个问题。
    ___No5:(不喜欢那个数字,直接跳了),Unable to resolve dependency for ':app@xxPreview/compileClasspath': Could not resolve project :library.
    Could not resolve project :library.
    Required by: project :app
    Unable to find a matching configuration of project :library:
    - Configuration 'debugApiElements':。。。
    这个比较恶毒,看着没啥毛病了,怎么会报依赖库的问题,感觉有点过分了,甚至很燥,想来一句mmp,本地依赖库还有啥该的,看了好久资料都没相关的说明,3.0也刚出来相关的更是少的不行(开会NO VPN),换了无数个关键词后发现一篇很有趣的文章,具体是啥我就不一一道来了,意思是现在的本地依赖库里面的build.gradle必须要和app里面的buildTypes一样,哪怕里面是空的debug,test,realease啥的也行,bingle解决了,粘过去就行了。
    好了天也不早了,今天就谈到这吧!

    相关文章

      网友评论

      • 7730b76d5e44:写的真好,大神!
        刘阿火:有六层楼好没
      • Leinyo:写得真好 大神
        刘阿火:@Leinyo 你知不知道我的效率有多高,简直了。。。别把塔斯科惹毛了
        Leinyo:@刘阿火 给你十天时间能写出来吗
        刘阿火:不吹不黑,过两天准备更新一篇神秘文章

      本文标题:浅谈Android Stduio升级3.0,Gradle升级4.

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