AndroidStudio 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
新版AndroidStudio3.1.2以上編譯的時候會檢查 項目依賴第三方庫是否是否使用了舊版的 依賴方法“compile” ,如果項目中存在大量“complie”依賴的第三方庫,會導致編譯失敗
解決方法:
方案一 將complie改成 “implementation”
比如:
在使用網絡請求框架 okhttp的時候在Gradle中需要添加:
compile ‘com.squareup.okhttp:okhttp:2.7.5’
建議改成:
implementation ‘com.squareup.okhttp:okhttp:2.7.5’
通常情況下,在舊項目升級了新版AndroidStudio3.1.2 或者更高版本之後,舊項目會遺留比較多的 “compile” 不好一個一個去改,這個時候可以先使用方案二
方案二
1,打開AndroidStudio > File > Settings
2,找到 Install Run > 取消所有chek選項 > apply > ok
方案二也是一時的能跳過編譯檢查,建議還是將項目中所有使用Compile 的地方換成 :implementation
ok~