1. 程式人生 > >Error:Could not determine the dependencies of task ':app:transformClassesWithInstantRunForDebug'.

Error:Could not determine the dependencies of task ':app:transformClassesWithInstantRunForDebug'.

Android Studio使用中,我們可能會遇到這種問題:Error:Could not determine the dependencies of task ':app:transformClassesWithInstantRunForDebug'. > In order to use Instant Run with this device running API 18, you must install platform 18 in your SDK。很多人一看到這個肯定要去下載API為18的SDK。如果我們拿不同版本的測試手機去安裝編譯apk時,同樣也會出現叫你安裝相對應的API,這樣不符合我們想要的,不可能叫我們從最低版本一直下載到最高的版本啊!這個問題的
解決辦法是:開啟你專案的Build.gradle中修改dependencies {classpath'com.android.tools.build:gradle:2.2.1'},我這裡是2.2.1把這個值修改為2.0.0。再重新編譯就會正常的執行安裝App了。注意:開啟的是你專案的Build.gradle,不是Module中的Build.gradle
       如果遇到不是關於需要下載對應的API的問題,只報':app:transformClassesWithInstantRunForDebug'.這個問題,那麼它的解決辦法是:開啟File——>settings——>Build,Execution,Deplyoment——>Instant Run——>把第一個勾選的給去掉再重新編譯。如圖:
去掉過後能正常的運行當前的專案,但是當你開啟另外一個專案執行時有可能會執行失敗。你們可以試試,如果失敗的話再把這個給勾上就是了。 不說了,最近專案比較緊,這個問題還是我擠出一點時間寫的。也是我所遇到也解決的問題,可能對大家遇到這類問題有所幫助!