When I turned minifyEnabled in build.gradle to true, seems like rxjava3 suddenly can't work as expected, when I go through the log and the API response correctly.
So what I do is create a empty new project.
Import Rxjava3 (3.0.13):
implementation "io.reactivex.rxjava3:rxjava:3.0.13"
Changed buildTypes to:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Simply give me "Test"
Single.just("Test")
.subscribe(new SingleObserver<String>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onSuccess(@NonNull String s) {
Log.d("TAG", s); // (s expect: "Test", get: null)
}
@Override
public void onError(@NonNull Throwable e) {
}
});
}
If you switch debug's minifyEnabled back to false, it will work as expected. I also add these lines in proguard-rules.pre file:
##---------------Begin: proguard configuration for rxjava ----------
-dontwarn java.util.concurrent.Flow*
##---------------End: proguard configuration for rxjava ----------
It did not work.
Can someone show me some way to go from here? Thank you in advance.
Try adding this instead in Proguard.
-dontwarn java.util.concurrent.**