Proguard:我可以添加什么规则来避免找不到引用类?

我有这样的功能:

private fun enableSearch() { parentActivity?.let { parentActivity -> parentActivity.searchParamsObs //This is for the first time, to avoid having an empty trolley .flatMap { searchParams -> Observable.combineLatest(searchService.search(searchParams).toObservable(), orderItemsService.getCachedTrolleyOrRequest(), BiFunction<SearchResults, TrolleyItemsResponse, SearchListResultsAndTrolley> { searchResults, trolleyItems -> SearchListResultsAndTrolley(searchResults, trolleyItems) }) } .subscribeIO() .observeMain() .subscribe( { updateScreenWithSearch(it) }, { e -> onSearchError(e) }) .addTo(disposables) parentActivity.focusSearchView() } } 

每次尝试使用proguard进行构建时,

  • com.my.package.features.search.fragments.ProductListFragment $ enableSearch $ 1 $ 1 $ 1:找不到引用的类

  • com.my.package.features.search.fragments.ProductListFragment $ enableSearch $ 1 $ 1

我已经指出问题是flatMap ..但我不明白为什么。

目前我有proguard下面的proguard配置:

 ########## # Android ########## -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -dontwarn android.databinding.** -keep class android.databinding.** { *; } -keepclassmembers class * extends android.content.Context { public void *(android.view.View); public void *(android.view.MenuItem); } -keep class android.support.v8.renderscript.** { *; } ########## # View - Gets and setters - keep setters in Views so that animations can still work. # see http://proguard.sourceforge.net/manual/examples.html#beans ########## -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); } ########## # Kotlin ########## -dontwarn kotlin.** -dontnote kotlin.** -keepclassmembers class **$WhenMappings { <fields>; } #Ignore null checks at runtime -assumenosideeffects class kotlin.jvm.internal.Intrinsics { static void checkParameterIsNotNull(java.lang.Object, java.lang.String); } ########## # RxJava ########## -keep class rx.schedulers.Schedulers { public static <methods>; } -keep class rx.schedulers.ImmediateScheduler { public <methods>; } -keep class rx.schedulers.TestScheduler { public <methods>; } -keep class rx.schedulers.Schedulers { public static ** test(); } -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { long producerIndex; long consumerIndex; } -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { long producerNode; long consumerNode; } 

包括在gradle中

实施“org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version”

$ kotlin_version = '51年1月1日'