In the project it has a class in OptionalDependencies.kt
package com.xyz.demo
import android.content.Context
import com.facebook.stetho.Stetho
import com.facebook.stetho.okhttp3.StethoInterceptor
import okhttp3.Interceptor
object OptionalDependencies {
fun initStetho(context: Context) {
Stetho.initializeWithDefaults(context)
}
fun getNetworkInterceptor() : Interceptor? = StethoInterceptor()
}
and in the StartActivity.kt
package com.xyz.demo.ui
import com.xyz.demo.OptionalDependencies
……
class StartActivity : AppCompatActivity() {
private fun initStetho(@ApplicationContext appContext: Context) {
val interceptor : Interceptor? =
OptionalDependencies.getNetworkInterceptor()//<=== any where will get error referring the
……
}
……
}
in the build.gradle
buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
in the proguard-rules.pro
-keep class com.xyz.demo.** {*;}
also tried -keep class com.xyz.demo.OptionalDependencies {*;}
get error:
e:/Users/sample/src/main/java/com/xyz/demo/ui/StartActivity.kt:
(527, 42): Unresolved reference: OptionalDependencies
if turn off the proguard it works fine.
I guess have to do a "sync" after made change to the proguard-rules.pro
, then re-build.