Cómo solucionar error: Dns.java okhttp3.Dns$1.búsqueda?

hace poco empecé a recibir tales accidentes. Nada se actualiza para tener tirantes. ¿Alguien sabe cuál es la causa de este problema? Gracias.

com.squareup.retrofit2:retrofit:

retrofitVersion = "2.6.1"; retrofitConverterGsonVersion = "2.6.1"; retrofitAdapterRxJava2Version = "2.6.1"

    Dns.java line 39
okhttp3.Dns$1.lookup

Fatal Exception: io.reactivex.exceptions.UndeliverableException
com.companyname.data.service.retrofit.exception.RetrofitException: Unable to resolve host "api.companyserver.com": No address associated with hostname
io.reactivex.plugins.RxJavaPlugins.onError (RxJavaPlugins.java:349)
io.reactivex.internal.operators.observable.ObservablePublish$PublishObserver.onError (ObservablePublish.java:187)
io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated (ObservableObserveOn.java:276)
io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal (ObservableObserveOn.java:172)
io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run (ObservableObserveOn.java:252)
io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run (HandlerScheduler.java:109)


Caused by com.companyname.data.service.retrofit.exception.RetrofitException
Unable to resolve host "api.companyserver.com": No address associated with hostname
com.lampa.letyshops.data.service.retrofit.adapter.RxErrorHandlingCallAdapterFactory$Rx2CallAdapterWrapper.asRetrofitException (RxErrorHandlingCallAdapterFactory.java:75)
com.lampa.letyshops.data.service.retrofit.adapter.RxErrorHandlingCallAdapterFactory$Rx2CallAdapterWrapper.access$000 (RxErrorHandlingCallAdapterFactory.java:41)
com.lampa.letyshops.data.service.retrofit.adapter.RxErrorHandlingCallAdapterFactory$Rx2CallAdapterWrapper$1.apply (RxErrorHandlingCallAdapterFactory.java:62)
com.lampa.letyshops.data.service.retrofit.adapter.RxErrorHandlingCallAdapterFactory$Rx2CallAdapterWrapper$1.apply (RxErrorHandlingCallAdapterFactory.java:59)
io.reactivex.internal.operators.observable.ObservableOnErrorNext$OnErrorNextObserver.onError (ObservableOnErrorNext.java:91)
retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onError (BodyObservable.java:72)
retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual (CallExecuteObservable.java:55)
io.reactivex.Observable.subscribe (Observable.java:10955)
retrofit2.adapter.rxjava2.BodyObservable.subscribeActual (BodyObservable.java:34)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableOnErrorNext.subscribeActual (ObservableOnErrorNext.java:38)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableMap.subscribeActual (ObservableMap.java:33)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableObserveOn.subscribeActual (ObservableObserveOn.java:45)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual (ObservableDoOnEach.java:42)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableMap.subscribeActual (ObservableMap.java:33)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableRetryWhen$RepeatWhenObserver.subscribeNext (ObservableRetryWhen.java:150)
io.reactivex.internal.operators.observable.ObservableRetryWhen$RepeatWhenObserver.innerNext (ObservableRetryWhen.java:127)
io.reactivex.internal.operators.observable.ObservableRetryWhen$RepeatWhenObserver$InnerRepeatObserver.onNext (ObservableRetryWhen.java:167)
io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit (ObservableFlatMap.java:262)
io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext (ObservableFlatMap.java:559)
io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onNext (ObservableCreate.java:67)
com.lampa.letyshops.data.manager.UnauthorizedManager.lambda$new$0 (UnauthorizedManager.java:61)
com.lampa.letyshops.data.manager.-$$Lambda$UnauthorizedManager$b3aT2iQy6aaX0AixSwB-wvEbg4w.subscribe
io.reactivex.internal.operators.observable.ObservableCreate.subscribeActual (ObservableCreate.java:40)
io.reactivex.Observable.subscribe (Observable.java:10955)
io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner (ObservableFlatMap.java:162)
io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext (ObservableFlatMap.java:139)
io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal (ObservableObserveOn.java:200)
io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run (ObservableObserveOn.java:252)
io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run (ExecutorScheduler.java:260)
io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run (ExecutorScheduler.java:225)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
0
2019-09-17 09:49:44
fuente
3 respuestas

Podemos utilizar un poco de regular la expresión de la magia para agarrar cualquier cosa que aparece antes de que el carácter":", a continuación, asignar los resultados a los nombres de columna del marco de datos:

df <- data.frame(x1 = "ID: 4",
                 x2 = "Start Date: 1946/11/13",
                 x3 = "End Date: 1946/12/31")

labels <- sapply(df[1, ], sub, pattern = '(?=:).*', replacement = '\\1', perl = T)
labels <- gsub(' ', '_', labels)
colnames(df) <- labels

> colnames(df)
[1] "ID"         "Start_Date" "End_Date"  
+0
2019-09-17 10:22:02
df <- data.frame(x1 = "ID: 4",
                 x2 = "Start Date: 1946/11/13",
                 x3 = "End Date: 1946/12/31", stringsAsFactors = F)

names(df) <- sapply(df[1,], function(x) {stringr::str_extract(x,"[^:]+") %%>%% stringr::str_replace(" ", "_")})
df <- rbind(df, sapply(df[1,], function(x) {stringr::str_extract(x,":.+$") %%>%% stringr::str_replace(": ", "")}))
df <- df[2, ]
+0
2019-09-17 10:22:02
nm = gsub("\\s", "_", sapply(df[1,], function(x) gsub("(.*):.*", "\\1", x)))
setNames(data.frame(lapply(df, function(x) gsub(".*:\\s?(.*)", "\\1", x))), nm)
#  ID Start_Date   End_Date
#1  4 1946/11/13 1946/12/31
+0
2019-09-17 10:22:02

Vea otras preguntas sobre etiquetas