{"id":714,"date":"2023-02-26T15:21:43","date_gmt":"2023-02-26T07:21:43","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=714"},"modified":"2023-04-29T17:16:28","modified_gmt":"2023-04-29T09:16:28","slug":"android-development-multidex-subcontracting-process","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/android-development-multidex-subcontracting-process\/","title":{"rendered":"Android\u5f00\u53d1MultiDex\u5206\u5305\u6d41\u7a0b"},"content":{"rendered":"<p>Android\u9879\u76ee\u65b9\u6cd5\u6570\u8d85\u8fc765536\uff08DEX 64K problem\uff09\uff0c\u5bfc\u81f4dex\u65e0\u6cd5\u751f\u6210\uff1a<\/p>\n<pre><code class=\"language-java\">Error:Executionfailed for task &#039;:app:transformClassesWithDexForDebug&#039;.\n\n>com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u9700\u8981\u8fdb\u884cMultiDex\u5206\u5305<\/p>\n<h3>\u6dfb\u52a0multidex\u4f9d\u8d56<\/h3>\n<pre><code class=\"language-java\">dependencies {\n   implementation &#039;com.android.support:multidex:1.0.3&#039;\n}<\/code><\/pre>\n<p>\u6700\u65b0\u7248\u672c\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/mvnrepository.com\/artifact\/com.android.support\/multidex\">https:\/\/mvnrepository.com\/artifact\/com.android.support\/multidex<\/a><\/p>\n<h3>\u5728defaultConfig\u4e2d\u8bbe\u7f6emultiDexEnabled\u6807\u7b7e\u4e3atrue<\/h3>\n<pre><code class=\"language-java\">defaultConfig {\n    multiDexEnabled true \n}<\/code><\/pre>\n<h3>\u521b\u5efaApplication\u5e76\u5728AndroidManifest.xml\u4e2d\u58f0\u660e<\/h3>\n<pre><code class=\"language-java\">public class MyApplication extends MultiDexApplication {\n\n    @Override\n    protected void attachBaseContext(Context base) {\n        super.attachBaseContext(base);\n        MultiDex.install(this);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-xml\">&lt;application android:name=&quot;.app.MyApplication&quot;&gt;\n\n&lt;\/application&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Android\u9879\u76ee\u65b9\u6cd5\u6570\u8d85\u8fc765536\uff08DEX 64K problem\uff09\uff0c\u5bfc\u81f4dex\u65e0\u6cd5\u751f\u6210\uff1a Error:E [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[202],"tags":[207],"class_list":["post-714","post","type-post","status-publish","format-standard","hentry","category-android-build","tag-multidex"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=714"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/714\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}