Solucionado (ver solução)
Solucionado
(ver solução)
14
respostas

HTTPCLIENT dando erro.

Estou utilizando o emulador do Visual studio e não estou obtendo os dados .

06-29 17:26:34.474 D/Mono    (13847): Unloading image System.Threading.Tasks.dll [0xb9314f20].
06-29 17:26:34.474 D/Mono    (13847): Image addref System.Threading.Tasks[0xb93156e0] -> System.Threading.Tasks.dll[0xb8ef7100]: 5
06-29 17:26:34.474 D/Mono    (13847): Config attempting to parse: 'System.Threading.Tasks.dll.config'.
06-29 17:26:34.474 D/Mono    (13847): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Threading.Tasks/System.Threading.Tasks.config'.
06-29 17:26:34.474 D/Mono    (13847): Assembly Ref addref App2[0xb8b93570] -> System.Threading.Tasks[0xb8ef7d50]: 3
06-29 17:26:34.602 D/Mono    (13847): Assembly Ref addref FormsViewGroup[0xb8b94540] -> Java.Interop[0xb8bbf220]: 3
06-29 17:26:34.606 D/Mono    (13847): Assembly Ref addref Xamarin.Forms.Platform.Android[0xb8b9d860] -> Xamarin.Android.Support.Design[0xb8b963a0]: 2
06-29 17:26:34.610 D/Mono    (13847): Assembly Ref addref Xamarin.Forms.Platform.Android[0xb8b9d860] -> Xamarin.Android.Support.v7.CardView[0xb8b98ed0]: 2
06-29 17:26:34.650 D/Mono    (13847): Assembly Ref addref Xamarin.Forms.Platform[0xb8b9e800] -> Xamarin.Forms.Core[0xb8b9c870]: 6
06-29 17:26:34.694 I/dalvikvm(13847): Could not find method android.view.ViewGroup.<init>, referenced from method md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.<init>
06-29 17:26:34.694 W/dalvikvm(13847): VFY: unable to resolve direct method 20617: Landroid/view/ViewGroup;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;II)V
06-29 17:26:34.694 D/dalvikvm(13847): VFY: replacing opcode 0x70 at 0x0000
06-29 17:26:34.754 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:34.754 D/Mono    (13847): Searching for 'java_interop_jnienv_call_static_int_method_a'.
06-29 17:26:34.754 D/Mono    (13847): Probing 'java_interop_jnienv_call_static_int_method_a'.
06-29 17:26:34.754 D/Mono    (13847): Found as 'java_interop_jnienv_call_static_int_method_a'.
06-29 17:26:34.798 D/Mono    (13847): Assembly Ref addref Mono.Android[0xb8ba04d0] -> System.Xml[0xb8efe1c0]: 3
06-29 17:26:34.806 I/dalvikvm(13847): Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
06-29 17:26:34.806 W/dalvikvm(13847): VFY: unable to resolve virtual method 442: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
06-29 17:26:34.806 D/dalvikvm(13847): VFY: replacing opcode 0x6e at 0x0002
06-29 17:26:34.806 I/dalvikvm(13847): Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
06-29 17:26:34.806 W/dalvikvm(13847): VFY: unable to resolve virtual method 444: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
06-29 17:26:34.806 D/dalvikvm(13847): VFY: replacing opcode 0x6e at 0x0002
06-29 17:26:34.818 D/dalvikvm(13847): GC_CONCURRENT freed 224K, 9% free 3016K/3296K, paused 9ms+0ms, total 12ms
06-29 17:26:34.830 D/Mono    (13847): Assembly Ref addref Xamarin.Android.Support.v7.AppCompat[0xb8b98060] -> System.Core[0xb8ceb870]: 7
06-29 17:26:34.854 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:34.854 D/Mono    (13847): Searching for 'java_interop_jnienv_call_void_method'.
06-29 17:26:34.854 D/Mono    (13847): Probing 'java_interop_jnienv_call_void_method'.
06-29 17:26:34.854 D/Mono    (13847): Found as 'java_interop_jnienv_call_void_method'.
06-29 17:26:34.918 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:34.922 D/Mono    (13847): Searching for 'java_interop_jnienv_call_nonvirtual_object_method'.
06-29 17:26:34.922 D/Mono    (13847): Probing 'java_interop_jnienv_call_nonvirtual_object_method'.
06-29 17:26:34.922 D/Mono    (13847): Found as 'java_interop_jnienv_call_nonvirtual_object_method'.
06-29 17:26:34.942 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:34.942 D/Mono    (13847): Searching for 'java_interop_jnienv_call_nonvirtual_int_method_a'.
06-29 17:26:34.942 D/Mono    (13847): Probing 'java_interop_jnienv_call_nonvirtual_int_method_a'.
06-29 17:26:34.942 D/Mono    (13847): Found as 'java_interop_jnienv_call_nonvirtual_int_method_a'.
06-29 17:26:34.942 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:34.942 D/Mono    (13847): Searching for 'java_interop_jnienv_call_int_method'.
06-29 17:26:34.942 D/Mono    (13847): Probing 'java_interop_jnienv_call_int_method'.
06-29 17:26:34.942 D/Mono    (13847): Found as 'java_interop_jnienv_call_int_method'.
06-29 17:26:34.958 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:34.958 D/Mono    (13847): Searching for 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
06-29 17:26:34.958 D/Mono    (13847): Probing 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
06-29 17:26:34.958 D/Mono    (13847): Found as 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
06-29 17:26:35.114 D/dalvikvm(13847): GC_FOR_ALLOC freed 18K, 8% free 3142K/3396K, paused 7ms, total 7ms
06-29 17:26:35.114 I/dalvikvm-heap(13847): Grow heap (frag case) to 4.215MB for 1150980-byte allocation
06-29 17:26:35.118 D/dalvikvm(13847): GC_FOR_ALLOC freed <1K, 6% free 4266K/4524K, paused 3ms, total 3ms
06-29 17:26:35.150 D/dalvikvm(13847): GC_CONCURRENT freed <1K, 6% free 4265K/4524K, paused 2ms+1ms, total 32ms
06-29 17:26:35.186 I/dalvikvm(13847): Could not find method android.view.ViewGroup.<init>, referenced from method md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer_Container.<init>
06-29 17:26:35.186 W/dalvikvm(13847): VFY: unable to resolve direct method 20617: Landroid/view/ViewGroup;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;II)V
06-29 17:26:35.186 D/dalvikvm(13847): VFY: replacing opcode 0x70 at 0x0000
06-29 17:26:35.282 I/dalvikvm(13847): Could not find method android.view.ViewGroup.<init>, referenced from method md5b60ffeb829f638581ab2bb9b1a7f4f3f.PageContainer.<init>
06-29 17:26:35.282 W/dalvikvm(13847): VFY: unable to resolve direct method 20617: Landroid/view/ViewGroup;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;II)V
06-29 17:26:35.282 D/dalvikvm(13847): VFY: replacing opcode 0x70 at 0x0000
06-29 17:26:35.290 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:35.290 D/Mono    (13847): Searching for 'java_interop_jnienv_new_local_ref'.
06-29 17:26:35.290 D/Mono    (13847): Probing 'java_interop_jnienv_new_local_ref'.
06-29 17:26:35.290 D/Mono    (13847): Found as 'java_interop_jnienv_new_local_ref'.
06-29 17:26:35.310 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:35.310 D/Mono    (13847): Searching for 'java_interop_jnienv_call_nonvirtual_boolean_method'.
06-29 17:26:35.310 D/Mono    (13847): Probing 'java_interop_jnienv_call_nonvirtual_boolean_method'.
06-29 17:26:35.310 D/Mono    (13847): Found as 'java_interop_jnienv_call_nonvirtual_boolean_method'.
06-29 17:26:35.322 W/Mono    (13847): The request to load the assembly System.Net.Http v1.5.0.0 was remapped to v2.0.5.0
06-29 17:26:35.322 D/Mono    (13847): Image addref System.Net.Http[0xb951c4c0] -> System.Net.Http.dll[0xb951c820]: 2
06-29 17:26:35.322 D/Mono    (13847): Prepared to set up assembly 'System.Net.Http' (System.Net.Http.dll)
06-29 17:26:35.322 D/Mono    (13847): Assembly System.Net.Http[0xb951c4c0] added to domain RootDomain, ref_count=1
06-29 17:26:35.322 D/Mono    (13847): AOT: image 'System.Net.Http.dll.so' not found: dlopen failed: library "/data/app-lib/App2.Android-1/libaot-System.Net.Http.dll.so" not found
06-29 17:26:35.322 D/Mono    (13847): AOT: image '/usr/local/lib/mono/aot-cache/x86/System.Net.Http.dll.so' not found: dlopen failed: library "/data/app-lib/App2.Android-1/libaot-System.Net.Http.dll.so" not found
06-29 17:26:35.322 D/Mono    (13847): Config attempting to parse: 'System.Net.Http.dll.config'.
06-29 17:26:35.322 D/Mono    (13847): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Net.Http/System.Net.Http.config'.
06-29 17:26:35.322 D/Mono    (13847): Assembly Ref addref App2[0xb8b93570] -> System.Net.Http[0xb951c4c0]: 2
06-29 17:26:35.322 D/Mono    (13847): Assembly Ref addref System.Net.Http[0xb951c4c0] -> mscorlib[0xb8b54010]: 37
Loaded assembly: System.Net.Http.dll [External]
Resolved pending breakpoint at 'ListagemViewModel.cs:42,1' to void App2.ViewModel.ListagemViewModel.<GetVeiculos>d__10.MoveNext () [0x000bf].
06-29 17:26:35.430 D/Mono    (13847): Assembly Ref addref System.Net.Http[0xb951c4c0] -> System[0xb8e42810]: 10
06-29 17:26:35.438 D/Mono    (13847): Unloading image System.Net.Http.dll [0xb952ef50].
06-29 17:26:35.438 D/Mono    (13847): Image addref System.Net.Http[0xb9509790] -> System.Net.Http.dll[0xb951c820]: 5
06-29 17:26:35.438 D/Mono    (13847): Config attempting to parse: 'System.Net.Http.dll.config'.
06-29 17:26:35.438 D/Mono    (13847): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Net.Http/System.Net.Http.config'.
Thread started:  #3
06-29 17:26:35.642 D/Mono    (13847): Image addref Mono.Security[0xb958b3c0] -> Mono.Security.dll[0xb958a730]: 2
06-29 17:26:35.642 D/Mono    (13847): Prepared to set up assembly 'Mono.Security' (Mono.Security.dll)
06-29 17:26:35.642 D/Mono    (13847): Assembly Mono.Security[0xb958b3c0] added to domain RootDomain, ref_count=1
06-29 17:26:35.642 D/Mono    (13847): AOT: image 'Mono.Security.dll.so' not found: dlopen failed: library "/data/app-lib/App2.Android-1/libaot-Mono.Security.dll.so" not found
06-29 17:26:35.642 D/Mono    (13847): AOT: image '/usr/local/lib/mono/aot-cache/x86/Mono.Security.dll.so' not found: dlopen failed: library "/data/app-lib/App2.Android-1/libaot-Mono.Security.dll.so" not found
06-29 17:26:35.642 D/Mono    (13847): Config attempting to parse: 'Mono.Security.dll.config'.
06-29 17:26:35.642 D/Mono    (13847): Config attempting to parse: '/usr/local/etc/mono/assemblies/Mono.Security/Mono.Security.config'.
06-29 17:26:35.642 D/Mono    (13847): Assembly Ref addref System[0xb8e42810] -> Mono.Security[0xb958b3c0]: 2
06-29 17:26:35.642 D/Mono    (13847): Assembly Ref addref Mono.Security[0xb958b3c0] -> mscorlib[0xb8b54010]: 38
Loaded assembly: Mono.Security.dll [External]
06-29 17:26:35.682 D/Mono    (13847): Assembly Ref addref System.Net.Http[0xb951c4c0] -> System.Core[0xb8ceb870]: 8
06-29 17:26:35.702 D/Mono    (13847): Assembly Ref addref Mono.Android[0xb8ba04d0] -> System[0xb8e42810]: 11
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
06-29 17:26:35.938 D/Mono    (13847): [0xb95ec310] worker starting
Thread started: <Thread Pool> #6
06-29 17:26:35.978 D/Mono    (13847): [0xb95ed2a0] worker starting
Thread started: <Thread Pool> #7
06-29 17:26:36.034 D/Mono    (13847): [0xb95ef0f0] worker starting
06-29 17:26:36.082 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:36.082 D/Mono    (13847): Searching for 'java_interop_jnienv_call_nonvirtual_void_method'.
06-29 17:26:36.082 D/Mono    (13847): Probing 'java_interop_jnienv_call_nonvirtual_void_method'.
06-29 17:26:36.082 D/Mono    (13847): Found as 'java_interop_jnienv_call_nonvirtual_void_method'.
06-29 17:26:36.166 D/Mono    (13847): [0xb95ec310] hill climbing, change max number of threads 2
06-29 17:26:36.210 D/GLHostConnection(13847): Waiting for host to establish connection for PID 13847 (App2.Android)
06-29 17:26:36.214 D/GLHostConnection(13847): HostConnection::get() New Host Connection established 0xb9697210, tid 13847
06-29 17:26:36.310 W/EGL_emulation(13847): eglSurfaceAttrib not implemented
06-29 17:26:36.314 D/OpenGLRenderer(13847): Enabling debug mode 0
06-29 17:26:36.418 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:26:36.418 D/Mono    (13847): Searching for 'java_interop_jnienv_call_nonvirtual_float_method_a'.
06-29 17:26:36.418 D/Mono    (13847): Probing 'java_interop_jnienv_call_nonvirtual_float_method_a'.
06-29 17:26:36.418 D/Mono    (13847): Found as 'java_interop_jnienv_call_nonvirtual_float_method_a'.
Thread finished: <Thread Pool> #6
06-29 17:27:06.926 D/Mono    (13847): [0xb95ed2a0] worker finishing
O thread 'Unknown' (0x6) foi fechado com o código 0 (0x0).
Thread finished: <Thread Pool> #5
06-29 17:27:25.498 D/Mono    (13847): [0xb95ec310] worker finishing
Thread started: <Thread Pool> #8
06-29 17:27:25.526 D/Mono    (13847): [0xb95ed2a0] worker starting
Thread started: <Thread Pool> #9
06-29 17:27:25.542 D/Mono    (13847): [0xb95ec310] worker starting
O thread 'Unknown' (0x5) foi fechado com o código 0 (0x0).
Thread finished: <Thread Pool> #4
Thread started: <Thread Pool> #10
O thread 'Unknown' (0x4) foi fechado com o código 0 (0x0).
06-29 17:27:56.330 D/Mono    (13847): DllImport searching in: '__Internal' ('(null)').
06-29 17:27:56.330 D/Mono    (13847): Searching for 'java_interop_jnienv_get_static_object_field'.
06-29 17:27:56.330 D/Mono    (13847): Probing 'java_interop_jnienv_get_static_object_field'.
06-29 17:27:56.330 D/Mono    (13847): Found as 'java_interop_jnienv_get_static_object_field'.
Thread finished: <Thread Pool> #8
06-29 17:28:25.918 D/Mono    (13847): [0xb95ed2a0] worker finishing
O thread 'Unknown' (0x8) foi fechado com o código 0 (0x0).
Thread finished: <Thread Pool> #10
O thread 'Unknown' (0xa) foi fechado com o código 0 (0x0).
Thread finished: <Thread Pool> #9
06-29 17:28:41.318 D/Mono    (13847): [0xb95ec310] worker finishing
O thread 'Unknown' (0x9) foi fechado com o código 0 (0x0).
14 respostas
const string URL_GET_VEICULO = "http://aluracar.herokuapp.com/";
public async Task GetVeiculos()
{
        HttpClient cliente = new HttpClient();
       var resultado = await cliente.GetStringAsync(URL_GET_VEICULO);
}

Olá, Airton!

Preciso de mais algumas informações, por gentileza.

  • Quando o programa chega na linha var resultado = await cliente.GetStringAsync(URL_GET_VEICULO) ele trava? Ou ocorre o erro? Aparece um erro na tela, ou apenas congela e não faz nada?
  • Qual a versão do Visual Studio você está utilizando?
  • Qual o nome do emulador que você está utilizando?

Obrigado!

Fala Marcelo

No momento que ele chega no método gerar erro quando chama var resultado = await cliente.GetStringAsync(URL_GET_VEICULO)

ele demora demais ,depois ele gera a mensagem An unhandled exception occured.

Estou usando Vs 2017

Você consegue pegar os detalhes da exceção "An unhandled exception occured"? Aí a gente poderia garimpar mais informações e ir mais diretamente ao problema.

Estou pegando Log do dispositivo,seria esse?

06-30 15:23:24.890 I/MonoDroid( 2641): at (wrapper dynamic-method) System.Object:e8462d4d-0099-4c08-aba5-f5491b04b997 (intptr,intptr) 06-30 15:23:24.902 D/Mono ( 2641): DllImport searching in: '__Internal' ('(null)'). 06-30 15:23:24.902 D/Mono ( 2641): Searching for 'java_interop_jnienv_throw'. 06-30 15:23:24.902 D/Mono ( 2641): Probing 'java_interop_jnienv_throw'. 06-30 15:23:24.902 D/Mono ( 2641): Found as 'java_interop_jnienv_throw'. 06-30 15:23:35.882 E/mono ( 2641): 06-30 15:23:35.882 E/mono ( 2641): Unhandled Exception: 06-30 15:23:35.882 E/mono ( 2641): System.Threading.Tasks.TaskCanceledException: A task was canceled. In mgmain JNI_OnLoad 06-30 15:23:35.882 E/mono-rt ( 2641): [ERROR] FATAL UNHANDLED EXCEPTION: System.Threading.Tasks.TaskCanceledException: A task was canceled.

Exception:

System.Threading.Tasks.TaskCanceledException: A task was canceled.

Opa, esse TaskCanceledException deu uma dica importante pra gente. Pode ser um problema de time out. Você consegue acessar o endereço http://aluracar.herokuapp.com/ no navegador do emulador ou do aparelho onde está dando erro? Dá um erro, ou aparecem os dados na página do navegador?

Marcelo é o seguinte eu estou usando emulador do Visual Studio Emulator for android com Hyper-V.

Pergunta como eu faço para dar acesso dentro desse emulador?

Então, abra o navegador dentro desse emulador e tente acessar http://aluracar.herokuapp.com/. Vamos ver se o navegador também responde com erro.

Não acessa estou sem acesso internet no meu emulador

Então o problema é esse. Você deveria poder acessar o navegador do emulador como um dispositivo qualquer. A imagem abaixo foi acessada no meu emulador:

Acesse a configuração Cellular Data do emulador e veja se não está desligada:

Settings > Data Usage > Cellular Data

Marcelo Boa Noite.

Esta relacionado a acesso a internet no meu note,obrigado mestre pelas dicas.

solução!

Legal, Airton, você conseguiu resolver então? Podemos fechar o chamado?

Sim Obrigado Marcelo.Grande Abraço e sucesso.