Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

之前用的studio是3.0,gradle是4.1 ,现在升级后studio版本变成3.1.2,gradle是4.4,然后就爆了很多的警告,这些警告不去除,app就不能成功运行。警告如下:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


Configuration 'debugCompile' is obsolete and has been replaced with 'debugImplementation' and 'debugApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


Configuration 'debugCompile' is obsolete and has been replaced with 'debugImplementation' and 'debugApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
...

大抵意思是:
关键词”compile”已经过时,已经被替换成关键词”implementation”或者”api”,就是compile会在2018年底被移除和替代。
那简单,我把所有的compile 、debugCompile、androidTestCompile都改为了implementation、debugImplementation、androidTestImplementation….反正所有包含compile的都改成了implementation。编译发现还是报警告:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.  
Configuration 'debugCompile' is obsolete and has been replaced with 'debugImplementation' and 'debugApi'.   

最初以为是我没有修改完全,于是仔细查看所有的build.gradle 文件,看看到底是哪个compile没有被修改(包含compile这个词汇的关键词也要被修改,例如:androidTestCompile,debugCompile,releaseCompile),最后发现都修改了,那到底是哪里出了错,最后查阅资料发现:我们依赖的library项目里面的compile,相当于library依赖了第三方库,被我们修改成了implementation之后app没有权限去访问第三方库了,所以继续报警告。于是我把library的implementation,releaseImplementation,debugImplementation改成了api,releaseApi,debugApi。编译之后,app成功运行。
api和implementation区别:
api 指令
完全等同于compile指令,没区别,你将所有的compile改成api,完全没有错。

implement指令
这个指令的特点就是,对于使用了该命令编译的依赖,对该项目有依赖的项目将无法访问到使用该命令编译的依赖中的任何程序,也就是将该依赖隐藏在内部,而不对外部公开

最后附上参考资料地址:
资料1
资料2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值