標籤:
關於此錯誤的出現的原因,請參照這篇微博http://www.05935.com/83/1036608/
使用Android Studio 2.0 引入老項目時,在開啟Instant Run時候會出現這樣的問題:
Error:Access to the dex task is now impossible, starting with 1.4.0 1.4.0 introduces a new Transform API allowing manipulation of the .class files. See more information: http://tools.android.com/tech-docs/new-build-system/transform-api
這個問題困擾了我好久,終於有了答案。
對於使用 gradle 2.2.1至2.9 版本的項目是無法使用Instant Run的,原因在於 Instant Run 需要使用 2.0.0的 Android Gradle Plugin:(現在2.0.0還是 alpaha 版)
但是,Android Gradle Plugin 從1.5.0開始就完全取消了Transform API,老項目還是使用了這個API,已至於項目更新後會報上文的錯誤。
詳見官方文檔(vpn)
而從官方文檔得知,使用 2.0.0的Android Gradle Plugin版本是支援1.5.0 的Android Gradle Plugin版本地,而不支援1.3.1以下版本
Gradle官方文檔(vpn)
換句話說就是目前為止只有使用的是 1.5.0 版本的項目才可以開啟 Instant Run,而使用1.3.1及以下版本的項目與無法開啟Instant Run
解決辦法================>:
百度Google均無效後,我多方折騰後找到解決辦法。
就是,在匯入舊項目後,android studio提示你升級項目,升級Instant,千萬不要點升級,點擊取消,然後繼續使用老版本的instant即可。
如果你已經點擊了升級,那就只有將項目恢複到舊版本,然後再匯入一次了。親測有效!
解決新版本android stuio 匯入舊項目出現 Error:Access to the dex task is now impossible, starting with 1.4.0 錯誤