android 方法數超過65k,解決dex方法數超過65536

來源:互聯網
上載者:User

標籤:65k   android應用程式方法超限   解決android dex檔案方法數過   

最近有朋友在問我,為什麼我就加了一個類/一個庫突然跑不起來了。

排查方式:

1、確認你的代碼/引用沒有問題2、檢查是否是65k問題

今天主要是解決 排查方式2的步驟,這個原因主要是因為你的apk包方法數過大。

現在解決這個已經很方便了:

方式一(繁瑣):程式分包,這個比較繁瑣;需要對jvm載入Class的方式有足夠的瞭解方式二(快速,使用AS):    1、使用google提供的分包庫    implementation ‘com.android.support:multidex:1.0.2‘    implementation ‘com.android.support:multidex-instrumentation:1.0.2‘    2、在主專案的build.gradle檔案裡設定 multiDexEnabled true

    3、如果項目有自訂的Application類,那就在它的onCreate方法裡加入  MultiDex.install(this);

    4、如果3不滿足,你需要在主專案的manifest檔案裡添加application標籤的name屬性為:    android.support.multidex.MultiDexApplication

android 方法數超過65k,解決dex方法數超過65536

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.