Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit 36a30e8

Browse files
Fixes serviceLoaderDebug variant
Fix: #1
1 parent a214ad7 commit 36a30e8

File tree

1 file changed

+4
-1
lines changed
  • app/src/serviceLoader/java/com/google/android/samples/dynamiccodeloading

1 file changed

+4
-1
lines changed

app/src/serviceLoader/java/com/google/android/samples/dynamiccodeloading/MainViewModel.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ class MainViewModel(app: Application) : AbstractMainViewModel(app) {
6060

6161
// Ask ServiceLoader for concrete implementations of StorageFeature.Provider
6262
// Explicitly use the 2-argument version of load to enable R8 optimization.
63-
val serviceLoader = ServiceLoader.load(StorageFeature.Provider::class.java, null)
63+
val serviceLoader = ServiceLoader.load(
64+
StorageFeature.Provider::class.java,
65+
StorageFeature.Provider::class.java.classLoader
66+
)
6467

6568
// Explicitly ONLY use the .iterator() method on the returned ServiceLoader to enable R8 optimization.
6669
// When these two conditions are met, R8 replaces ServiceLoader calls with direct object instantiation.

0 commit comments

Comments
 (0)