J'ai défini les mêmes types de build pour le débogage et la publication,
buildTypes {
debug {
buildConfigField "String", "API_BASE_URL", "\"https://www.testUrl.com/api/\""
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release_key
}
release {
buildConfigField "String", "API_BASE_URL", "\"https://www.testUrl.com/api/\""
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release_key
}
}
Mais si je compile avec la version, j'ai l'erreur ci-dessous. De plus, la réponse du serveur est exactement la même.
W/System.err: Java.lang.NullPointerException: The mapper function returned a null value.
W/System.err: at b.a.e.b.b.a(Unknown Source)
W/System.err: at b.a.e.e.b.bs$a.onNext(Unknown Source)
W/System.err: at b.a.e.e.b.cm$a.onNext(Unknown Source)
W/System.err: at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(Unknown Source)
W/System.err: at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(Unknown Source)
W/System.err: at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(Unknown Source)
W/System.err: at b.a.l.subscribe(Unknown Source)
W/System.err: at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(Unknown Source)
W/System.err: at b.a.l.subscribe(Unknown Source)
W/System.err: at b.a.e.e.b.cm$a.a(Unknown Source)
W/System.err: at b.a.e.e.b.cm.subscribeActual(Unknown Source)
W/System.err: at b.a.l.subscribe(Unknown Source)
W/System.err: at b.a.e.e.b.bs.subscribeActual(Unknown Source)
W/System.err: at b.a.l.subscribe(Unknown Source)
W/System.err: at b.a.e.e.b.bw.subscribeActual(Unknown Source)
W/System.err: at b.a.l.subscribe(Unknown Source)
W/System.err: at b.a.e.e.b.dd$b.run(Unknown Source)
W/System.err: at b.a.s$a.run(Unknown Source)
W/System.err: at b.a.e.g.j.run(Unknown Source)
W/System.err: at b.a.e.g.j.call(Unknown Source)
W/System.err: at Java.util.concurrent.FutureTask.run(FutureTask.Java:237)
W/System.err: at Java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.Java:272)
W/System.err: at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1133)
W/System.err: at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:607)
W/System.err: at Java.lang.Thread.run(Thread.Java:761)
Le problème vient de RxJava 2, qui ne permettra pas aux valeurs null
d'être transmises dans le flux. Dans votre cas en particulier, vous disposez d'une fonction de mappage, qui renvoie une valeur null
, que l'exception indique clairement.
Vous pouvez reproduire cela avec le morceau de code suivant:
Observable.just(1)
.map(integer -> null)
.test()
.assertError(throwable ->
"The mapper function returned a null value.".equals(throwable.getMessage()));