Faced the following problem: it is necessary to parse the data from the JSON file located on a specific link. For this I use the classes org.json. *. To access the Internet connection in AndroidManifest I specify the following:

<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

But when I run the application on Android 6, I get the following exception:

Permission denied (missing INTERNET permission?)

I read about the Runtime Permissions in the Android docks and realized that perhaps the problem lies in the fact that android.permission.INTERNET is a dangerous resolution and will have to add a couple of methods to request permission during program execution. But googling stumbled upon such an article from Habr , which indicates that access to the Internet is not dangerous. So what's the problem then?

upd: AndroidManifest.xml file

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.cargomart.cargomart" > <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 
  • Perhaps you have not registered permissions there? Show the entire manifesto - YuriySPb
  • Unfortunately, AndroidManifest exceeds the number of valid characters in a comment. Permissions prescribed between <manifest ...> and <application ...> tags - osip_000
  • It is better to supplement the question by editing the question, not in the comments - YuriySPb
  • What are your compileSdkVersion and targetSdkVersion ? - post_zeew 2:49
  • @post_zeew, 23 stands. I tried your solution, it didn’t work either - osip_000

1 answer 1

Hmm ... and the Android Studio environment itself, sdk, build tools - is everything fresh? Here we recognized a similar problem 3 years ago, https://www.parse.com/questions/android-sdk-parseasynctask-runtimeexception , but promised to fix it in future versions of sdk. Maybe a relapse. Try to write to them. And by the way, it would be nice to see a piece of code that you have associated with an Internet connection, although I doubt that we will learn something useful from there, and your build.gradle ...