Recent

Author Topic: Android 9 do not GetAsync , empty response  (Read 1166 times)

juank1971

  • Full Member
  • ***
  • Posts: 112
Android 9 do not GetAsync , empty response
« on: September 08, 2020, 11:53:03 pm »
hello, when I try to compile demo appHTTPClientDemo1 and it works perfectly in android 6 but when I compile the apk for android 9 it works but the GetAsync does not return data, response is empty.

vags15

  • New member
  • *
  • Posts: 7
Re: Android 9 do not GetAsync , empty response
« Reply #1 on: September 11, 2020, 05:09:25 am »

Hello, good night in the version, nor do I remember Android 8 or 9 forward, the reading of url is disabled. For that you must manually activate the activation.
You can make directly or create separate file below.
In the folder res /xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

Modify in the ./AndroidManifest.xml file
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
   android:networkSecurityConfig="@xml/network_security_config"> >agregar esta linea y compilar su proyecto

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android 9 do not GetAsync , empty response
« Reply #2 on: September 13, 2020, 08:38:44 pm »

Hi, juank1971

This solve your issue?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

juank1971

  • Full Member
  • ***
  • Posts: 112
Re: Android 9 do not GetAsync , empty response
« Reply #3 on: September 15, 2020, 05:45:54 pm »
Y try bat not compile
This ide error

Panic:      [echo] Handling Resources...
Panic:      [aapt] Generating resource IDs...
Panic:      [aapt] D:\ProyectosLazarus\android\AppHttpClientDemo1\bin\AndroidManifest.xml:31: error: Error: No resource found that matches the given name (at 'networkSecurityConfig' with value '@xml/network_security_config').
Panic:      [aapt]
Panic:
Panic: BUILD FAILED

juank1971

  • Full Member
  • ***
  • Posts: 112
Re: Android 9 do not GetAsync , empty response
« Reply #4 on: September 15, 2020, 06:36:54 pm »
Is done worked

Only this
 <application    android:usesCleartextTraffic="true"

In AndroidManifest.xml

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android 9 do not GetAsync , empty response
« Reply #5 on: September 15, 2020, 09:00:09 pm »

Quote
Only this
 <application    android:usesCleartextTraffic="true"

Ok. I will fix/update the "AndroidManifest.txt" template
in LAMW folder ".....\android_wizard\smartdesigner\java"

Thansk to All!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

juank1971

  • Full Member
  • ***
  • Posts: 112
Re: Android 9 do not GetAsync , empty response
« Reply #6 on: September 16, 2020, 04:25:53 am »
That code

 <application    android:usesCleartextTraffic="true"

was suggested by the user SEGATOR my friend a while ago but I tried it and somehow it didn't work for me. so I was doing the accesses with synapse but since synapse does not have getasync segator it suggested that I use jasynctask component but it is giving me application blocking problems sometimes. With rest connections

so I am trying again to return to the jhttpclient component. see if it works better with the rest server connections.


 

TinyPortal © 2005-2018