'Android App doesn't have internet connection - No Permissions required
Well, I have built an app to store values on a remote database. It works!! I didn't use an emulator for testing instead I used my own phone. Now the problem is that on my phone, it works perfectly...no issues but when I installed it on another phone, the app doesn't connect to the internet. I have included internet permission in android manifest.xml.
I have tried these but didn't work:
- Building apk and installing in the new phone.
- Compiling directly to the new phone.
- Sending the apk from old phone to new phone via shareit.
- Creating a signed apk and installing.
- Checked via wifi and mobile data (NOTE: BOTH WIFI AND MOBILE DATA WORKS IN OLD PHONE).
- Checked android compatibility: supports up to android 10.
*I added error messages for try...catch blocks in form of toasts for the user to know what's the issue. and the catch exception for no internet returns connection problem. I'm getting that error message.
As I researched, I got to know that internet permission is categorized as normal permission which is not prompted to the user upon installation.
I built a second dummy app: Same issue with it... compiled directly to new phone but didn't work...it works in old phone...
Old phone: Samsung J7 Prime with Android 8.1 New Phone: Samsung J7 Pro with Android 9
Any idea or suggestion will be gladly helpful... Thank you!
Solution 1:[1]
in android 9 and above you have to set network Security Config
first of all in res package create xml package and in xml package create new xml resource file with network_security_config name
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
then in manifest in
android:networkSecurityConfig="@xml/network_security_config"
Solution 2:[2]
<uses-permission android:name="android.permission.INTERNET" />
Solution 3:[3]
Use debug APK instead of signed APK
Solution 4:[4]
please add permission on Manifest to give a permission of permission.INTERNET
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | alireza rajaei |
Solution 2 | borchvm |
Solution 3 | Avinesh |
Solution 4 | Mukeem shiekh abdul |