@@ -207,6 +207,23 @@ nimbus {
207
207
experimenterManifest = " .experimenter.yaml"
208
208
}
209
209
210
+ configurations {
211
+ // There's an interaction between Gradle's resolution of dependencies with different types
212
+ // (@jar, @aar) for `implementation` and `testImplementation` and with Android Studio's built-in
213
+ // JUnit test runner. The runtime classpath in the built-in JUnit test runner gets the
214
+ // dependency from the `implementation`, which is type @aar, and therefore the JNA dependency
215
+ // doesn't provide the JNI dispatch libraries in the correct Java resource directories. I think
216
+ // what's happening is that @aar type in `implementation` resolves to the @jar type in
217
+ // `testImplementation`, and that it wins the dependency resolution battle.
218
+ //
219
+ // A workaround is to add a new configuration which depends on the @jar type and to reference
220
+ // the underlying JAR file directly in `testImplementation`. This JAR file doesn't resolve to
221
+ // the @aar type in `implementation`. This works when invoked via `gradle`, but also sets the
222
+ // correct runtime classpath when invoked with Android Studio's built-in JUnit test runner.
223
+ // Success!
224
+ jnaForTest
225
+ }
226
+
210
227
dependencies {
211
228
implementation FocusDependencies . androidx_appcompat
212
229
implementation FocusDependencies . androidx_browser
@@ -304,6 +321,8 @@ dependencies {
304
321
focusImplementation FocusDependencies . adjust
305
322
focusImplementation FocusDependencies . install_referrer // Required by Adjust
306
323
324
+ jnaForTest FocusDependencies . jna
325
+ testImplementation files(configurations. jnaForTest. copyRecursive(). files)
307
326
testImplementation " org.mozilla.telemetry:glean-native-forUnitTests:${ project.ext.glean_version} "
308
327
309
328
testImplementation FocusDependencies . testing_junit_api
0 commit comments