解決Configuration 'compile' is obsolete and has been replaced with implementation


項目中Gradle版本升級到4.4后,項目構建時,每次出現紅色的警告信息:

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018 Affected Modules: MyCorn-MyCorn 復制代碼

但本地項目代碼中compile都已經完成了implementation,警告信息依然出現。 一開始百思不得解,警告信息相對過於簡單,且對應模塊也已經全部完成了替換。

最終考慮使用命令進行項目構建過程,以期望能獲取具體的進一步詳情信息,因此,輸出完整debug日志。

 ./gradlew assembleDevDebug --debug  >  ~/T/gralde.log 
復制代碼

輸出的gralde.log日志信息很大,搜索對應的警告信息。

...
17:17:48.796 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Apply plugin corn-auto-collector to project ':MyCorn'' started 17:17:48.802 [DEBUG] [org.gradle.api.internal.artifacts.mvnsettings.DefaultLocalMavenRepositoryLocator] No local repository in Settings file defined. Using default path: /Users/corn/.m2/repository 17:17:48.805 [WARN] [org.gradle.api.Project] WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018 17:17:48.860 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Apply plugin corn-auto-collector to project ':MyCorn'' ... 復制代碼

對應的,我們發現是項目中應用了自實現的corn-auto-collector插件,而插件中並未將compile替換成implementation

修改對應插件的依賴配置,重新構建發現警告信息消失。

Android Studio默認構建時日志是-q級別輸出,在必要的時候我們可以修改默認構建日志輸出級別。 最常用的有兩種方式:
1,修改Android Studio >> Preferences >> Build >> Compiler >> Command-line Options,加入對應日志級別參數,如常用的--debug,--stacktrace
2,直接使用對應的gradle命令,加上對應的命令參數。

實際項目構建過程中,出現的構建問題,往往日志信息都很簡單,並不能一次性定位到問題所在,通過附加參數形式的去獲取完整的日志信息,以便詳細定位到項目構建過程中的具體問題,非常有效,在實際項目構建過程可以經常使用。


作者:HappyCorn
鏈接:https://juejin.im/post/5caf35d7e51d456e7079f1f0
來源:掘金
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM