解決新版本android stuio 匯入舊項目出現 Error:Access to the dex task is now impossible, starting with 1.4.0 錯誤

來源:互聯網
上載者:User

標籤:

關於此錯誤的出現的原因,請參照這篇微博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 錯誤

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.