Android Question CLEARTEXT communication to 192.168.0.101 not permitted by network security policy

beelze69

Active Member
Licensed User
Longtime User
Hi All,

I tried to implement the JRDC2 implementation of Erel in one program.

The implementation of Erel is in the below URL:


I get the following error:

ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.101 not permitted by network security policy, Response:
ERROR: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.101 not permitted by network security policy
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.101 not permitted by network security policy, Response:
ERROR: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.101 not permitted by network security policy

I have done the folllowing:

1) Opened 17178 port on my PC firewall (both INBOUND and OUTBOUND)
2) My JRDC2 server is running successfully.

Issue 1) However I am unable to fetch any data on the B4A application.

Issue 2) Hence I attempted to directly compile it to the device and try it from there but I am getting the above error message which I typed above.

Issue 3) I made the entry
android:usesCleartextTraffic="true" in the Androidmanifest.xml in the 'Objects' folder of my application and recompiled it successfully.
However, when I again open my Androidmanifest.xml file , it DOES NOT show the entry ..
So , is the Androidmanifest.xml being picked up from somewhere else everytime the compilation is being done by the IDE .. If so , from where ?



Please help..
 
Solution

Add below to your Manifest Editor:

B4X:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)

aeric

Expert
Licensed User
Longtime User

Add below to your Manifest Editor:

B4X:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)
 
Upvote 1
Solution

JohnC

Expert
Licensed User
Longtime User
You need to *always* edit the manifest file from the IDE using "Project....Manifest Editor" (in other words don't edit it in the objects folder).
 
Upvote 1

drgottjr

Expert
Licensed User
Longtime User
Issue 3) I made the entry
android:usesCleartextTraffic="true" in the Androidmanifest.xml in the 'Objects' folder of my application and recompiled it successfully.
However, when I again open my Androidmanifest.xml file , it DOES NOT show the entry ..
So , is the Androidmanifest.xml being picked up from somewhere else everytime the compilation is being done by the IDE .. If so , from where ?

use the manifest editer from within the ide. not the manifest in the objects folder. it gets clobbered when you compile.
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
So reduce the target sdk to <=26 (or so). Whith newer Android versions it's not allowed anymore to communicate without SSL (= "Cleartext").
Hi KMatle,

Strangely it worked for me with Target SDK version = 28 .. I also removed the entry android:usesCleartextTraffic="true" . However, I put the entry advised by aeric

viz.
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)

And it worked for me.. In fact, many have suggested the way you have done viz. reducing the Target SDK to <=26..

But somehow it worked for me with 28

Thank you very much for helping ..
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User

Add below to your Manifest Editor:

B4X:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)

Hi aeric !

Thank you very much ! Your tip worked for me ! I also removed the entry android:usesCleartextTraffic="true" .. It seems that is also not required.
Actually I am still learning.
Thank you very much for helping me.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Hi aeric !

Thank you very much ! Your tip worked for me ! I also removed the entry android:usesCleartextTraffic="true" .. It seems that is also not required.
Actually I am still learning.
Thank you very much for helping me.
This is how the community works. We help each other by providing solutions. Sometimes it is a working solution and sometimes not. Someone may have faced the same issue before so you may found the answer using the search box on top of this forum.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I also removed the entry android:usesCleartextTraffic="true" .. It seems that is also not required

The format I use for that option in B4A is:
B4X:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

The CreateResourceFromFile(Macro, Core.NetworkClearText) is a macro that creates the above line in the manifest when compiled - so the two basically do the same thing - you could include either one and it will work.

But the original reason why it wasn't working for you was because you were trying to edit the manifest file from outside the IDE and that's why your edits didn't "stick".

I am glad you got it working :)
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User

Add below to your Manifest Editor:

B4X:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)
The format I use for that option in B4A is:
B4X:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

The CreateResourceFromFile(Macro, Core.NetworkClearText) is a macro that creates the above line in the manifest when compiled - so the two basically do the same thing - you could include either one and it will work.

But the original reason why it wasn't working for you was because you were trying to edit the manifest file from outside the IDE and that's why your edits didn't "stick".

I am glad you got it working :)
Hi John !

I will also try your way.. Thank you very much
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I will also try your way.. Thank you very much

No need to use "my" way - #@aeric 's way is basically the same thing.

I just wanted to make sure that you knew to always edit the manifest from within the IDE and not out of it - that's all.
 
Upvote 0

CanelaKid

Member
Licensed User
Longtime User
The format I use for that option in B4A is:
B4X:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

The CreateResourceFromFile(Macro, Core.NetworkClearText) is a macro that creates the above line in the manifest when compiled - so the two basically do the same thing - you could include either one and it will work.

But the original reason why it wasn't working for you was because you were trying to edit the manifest file from outside the IDE and that's why your edits didn't "stick".

I am glad you got it working :)
Also worked for me, no problem. Thanks for the solution
 
Upvote 0
Top