0

リリースビルド タイプでインストルメンテーション テストを実行しようとしています。私のセットアップは次のとおりです。

Android Studio - 3.4.1
Android Gradle Plugin - 3.4.1
Gragle - 5.4.1
R8 - Enabled (default)

関連するbuild.gradleスニペット:

    testBuildType "release"

    buildTypes {
        release {
            proguardFiles fileTree(dir: 'vendor', include: ['*.pro']).asList().toArray()
            debuggable true
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            testProguardFile 'proguard-rules-test.pro'
            testCoverageEnabled false
        }
    }

proguard-rules-test.pro の内容 (テスト用):

-keep public class ** { *; }

インストルメンテーションを実行すると、次の実行時例外が発生します。

com.MYAPP.debug E/InstrumentationResultPrinter: Failed to mark test No Tests as finished after process crash
com.MYAPP.debug E/MonitoringInstr: Exception encountered by: Thread[main,5,main]. Dumping thread state to outputs and pining for the fjords.
    java.lang.NoSuchMethodError: No virtual method setAppComponent(L/com/MYAPP/injection/AppComponent;)V in class L/com/MYAPP/data/common/MyApplication$Companion; or its super classes (declaration of 'com.MYAPP.data.common.MyApplication$Companion' appears in /data/app/com.MYAPP.debug-o3QrzyIOGC0Ko3XRS2fcxQ==/base.apk)
        at com.MYAPP.base.TestMyApplication.h(TestMyApplication.kt:20)
        at com.MYAPP.data.common.MyApplication.onCreate(MyApplication.kt:126)

( TestMyApplicationMyApplicationを拡張し、 AndroidJUnitRunnerによって呼び出されます)

-keep行をproguard-rules-test.proからメインの Proguard ルール ファイルに移動すると、テストが実行され、問題なく合格します。

何か案は?

4

1 に答える 1