From d0e2652ef04346359a45794130857f1671940dfd Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Mon, 17 Oct 2022 17:39:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3dex=E8=B6=85=E8=BF=876?= =?UTF-8?q?4k=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 16 ++++++++++++++-- .../project/devcontrol/MainActivity.java | 8 ++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9b1d5b6..2448cb3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,8 @@ android { versionCode 1 versionName "1.0" + multiDexEnabled true + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -29,6 +31,10 @@ android { buildFeatures { viewBinding true } + + dexOptions { + javaMaxHeapSize "4g" + } } dependencies { @@ -42,9 +48,15 @@ dependencies { implementation 'androidx.navigation:navigation-ui:2.5.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.gridlayout:gridlayout:1.0.0' + + // hutool + implementation 'cn.hutool:hutool-all:5.8.8' + + // 解决 dex文件数超过64k问题 + implementation 'com.android.support:multidex:1.0.1' + + // 测试类资源 testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - - implementation 'cn.hutool:hutool-all:5.8.8' } \ No newline at end of file diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java index d8d2408..ee704ee 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java @@ -1,6 +1,8 @@ package cc.niushuai.project.devcontrol; +import android.content.Context; import android.os.Bundle; +import android.support.multidex.MultiDex; import androidx.appcompat.app.AppCompatActivity; import androidx.navigation.NavController; @@ -67,4 +69,10 @@ public class MainActivity extends AppCompatActivity { // 底部栏显示 NavigationUI.setupWithNavController(activityMainBinding.bottomNavView, navController); } + + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(newBase); + MultiDex.install(this); + } } \ No newline at end of file