Skip to content

Commit

Permalink
test: 测试multidex
Browse files Browse the repository at this point in the history
和普通应用相比,需要额外在multiDexKeepProguard中添加对PluginManifest的keep。

在Android 4.4 API 19的虚拟机上可测试。
  • Loading branch information
shifujun committed Nov 28, 2023
1 parent 34eb796 commit 8aae258
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions projects/sample/source/sample-plugin/sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ android {
targetSdkVersion project.TARGET_SDK_VERSION
versionCode project.VERSION_CODE
versionName project.VERSION_NAME
multiDexEnabled true
multiDexKeepProguard file('multidex-config.pro')
}

dexOptions {
additionalParameters += '--minimal-main-dex'//为了测试Multidex能力
}


buildTypes {
release {
minifyEnabled true
Expand Down Expand Up @@ -68,6 +75,8 @@ dependencies {
//Shadow Transform后业务代码会有一部分实际引用runtime中的类
//如果不以compileOnly方式依赖,会导致其他Transform或者Proguard找不到这些类
pluginCompileOnly 'com.tencent.shadow.core:runtime'

implementation 'androidx.multidex:multidex:2.0.1'
}

preBuild.dependsOn(":sample-host-lib:jarDebugPackage")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-keep class androidx.multidex.**
-keep class com.tencent.shadow.core.manifest_parser.PluginManifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import static com.tencent.shadow.sample.plugin.app.lib.gallery.cases.UseCaseManager.useCases;

import android.app.Application;
import android.content.Context;

import androidx.multidex.MultiDex;

import com.tencent.shadow.sample.plugin.app.lib.gallery.cases.UseCaseManager;
import com.tencent.shadow.sample.plugin.app.lib.gallery.cases.entity.UseCase;
Expand All @@ -29,6 +32,13 @@
import com.tencent.shadow.sample.plugin.app.lib.usecases.webview.WebViewActivity;

public class UseCaseApplication extends Application {

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

@Override
public void onCreate() {
super.onCreate();
Expand Down

0 comments on commit 8aae258

Please sign in to comment.