I'm using Visual Studio 2015, min sdk version 14. I have read everywhere that after building a release version you need to specify internet permssions in the manifest. (although some people say that it's only neccessary if your a building for android version below x version).
This is a extract of my manifest:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="<app name>" android:icon="@drawable/icon"></application>
The thing is that when building and running straight from Visual to my device, I can't access internet from my app.
In the device's application manager I can see that the permissions assigned to my app are the following (wether it's deployed from visual studio or installed from Google Play):
- Modify or delete the contents of your USB storage
- Full Network access
- View Network Connections
On the other hand, when uploading the app to Goolge Play (alpha test), when I click install in my phone, the popup that shows the permissions that the app is going to use, shows it needs is "Access to Photos/Media/Files"
[EDIT] The way my app is accessing internet is through a PCL Project. Basically this is the chunk of code that does (or does not) all the magic.
try
{
if (CheckIfThereIsConnection())
{
HttpWebRequest request = WebRequest.Create(urlRequest) as HttpWebRequest;
request.Headers[HttpRequestHeader.Authorization] = "my token here";
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream stream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(stream);
string line = string.Empty;
StringBuilder sb = new StringBuilder();
while ((line = reader.ReadLine()) != null)
{
sb.Append(line);
}
T deserializedObject = JsonConvert.DeserializeObject<T>(sb.ToString());
return deserializedObject;
}
}
}
}
catch (Exception ex)
{
throw new Exception("My custom Exception", ex.InnerException);
}
I've looked everywhere whitout any luck. Could someone provide me a further and detailed explanation, or point me out some documents to have a look??
You are most likely running into an issue with the
Linker
stripping away something that your application needs. I would highly recommend that you review our documentation on this topic here:https://developer.xamarin.com/guides/android/advanced_topics/linking/#Linker_Behavior
You can then attempt to use
linkskip
(https://developer.xamarin.com/guides/android/advanced_topics/linking/#linkskip) or a custom linker configuration file(https://developer.xamarin.com/guides/cross-platform/advanced/custom_linking/) to ensure your assemblies are included in your final package.