I am new at Unity but I have some experience at Asp.Net programming. I need to develop a application which need to connect an API and get,post,delete some datas from that API. In order to achieve that, I am using these libraries below:
using System.Net.Http;
using System;
using Newtonsoft.Json;
When I run the application, there is no any error, warning etc. on my computer (I am using Unity 2020.3.24f1). It works exactly how I want. But when I build it for android platform (apk) and install it to my android phone, my codes which use these libraries does not work on the phone. I can not see any error on the phone screen just does not work. I hope I could explain.
CodePudding user response:
There is no "Unity System" .. you are using the general c#
System
and System.Net.Http
namespaces! And in general from System.Net
Classes in the System.Net namespace can be used to develop Windows Store apps or desktop apps.
so this doesn't exist on Android
.
You should rather use Unity's UnityWebRequest.Get
, UnityWebRequest.Post
and UnityWebRequest.Delete
accordingly.
For JSON either stick to the built-in JsonUtility
if possible or make sure to use the "semi-built-in" package Newtonsoft JSON you can install via the Package Manager (if it is not the case anyway for newer versions by default).