ms-intune-app-sdk-android
ms-intune-app-sdk-android copied to clipboard
Intune Plugin fails when we use shared modules between androidTest and test
Describe the bug:
Android allows creating shared modules which can host code that can be called from androidTest and test source sets. When we create the same and add a dependency of app
module in the sharedTest
module, the tests inside androidTest
module start failing.
To Reproduce Steps to reproduce the behavior:
- Clone this repository https://github.com/shubhamgarg1/IntuneCodeCoverageNotWorking/tree/intune_plugin_fails_with_shared_test_module
- Run ExampleTest inside androidTest folder of
app
Module and see the crash.
Expected behavior: The application should not crash.
Screenshots and logs:
java.lang.RuntimeException: Failed to instantiate test runner class androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
at androidx.test.ext.junit.runners.AndroidJUnit4.throwInitializationError(AndroidJUnit4.java:129)
at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:121)
at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:82)
at androidx.test.ext.junit.runners.AndroidJUnit4.<init>(AndroidJUnit4.java:56)
... 14 trimmed
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:112)
... 17 more
Caused by: java.lang.LinkageError: Method void com.example.intunesample.MainActivity.onCreate(android.os.Bundle) overrides final method in class Lcom/microsoft/intune/mam/client/app/MAMActivity; (declaration of 'com.example.intunesample.MainActivity' appears in /data/app/~~9WrYqv6kUnCvn8e_AEwJ6w==/com.example.intunesample.test-Eu63gUS8rKwyKiJ-SeVp9g==/base.apk)
at java.lang.reflect.Executable.getParameterTypesInternal(Native Method)
at java.lang.reflect.Method.getParameterTypes(Method.java:186)
at java.lang.Class.getDeclaredMethods(Class.java:1915)
at org.junit.internal.MethodSorter.getDeclaredMethods(MethodSorter.java:54)
at org.junit.runners.model.TestClass.scanAnnotatedMembers(TestClass.java:65)
at org.junit.runners.model.TestClass.<init>(TestClass.java:57)
at org.junit.runners.ParentRunner.createTestClass(ParentRunner.java:111)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:91)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:74)
at androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner.<init>(AndroidJUnit4ClassRunner.java:43)
at androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner.<init>(AndroidJUnit4ClassRunner.java:48)
... 20 more
Intune App SDK for Android (please complete the following information): -What version of the Intune SDK are you using? Are you using the latest version? Yes -What platform is your app based in (Java, Xamarin based, Cordova, etc)? Java -For errors during build, does the app build without Intune SDK integration? No -For errors post build, does the app launch without being Intune SDK integrated? No -Who is the customer? Adobe -Do you see a trend with it only being reproduced on a specific device? No
Additional context: It does not crash when we don't apply the intune plugin in the app module.
Hello, Thanks for the report. This is a known issue, tracked internally by #17339673. Does using the new build plugin (9.4.0) help? This uses a higher version of the Gradle plugin which may help this issue.