I'm using Retrofit to parse a JSON returned by the API in this link using POJO Model Classes as mentioned in Retrofit Documentation I use asynchronous method to successfully get the tags inside "entities". However, when I try to get the "profile" tag from the "Media", I get a Null pointer exception and the App crashes.
I tried printing the "Profile" data from Media tag to the LogCat, the App crashes but I can see the URL string printed in LogCat along with Null Pointer Exception for the same method.
This is confusing as my method returns the mapped Data from API but, still shows Null Pointer Exception.
Related
I'm using retrofit for a network request, but I found a very weird situation, so for some reason my object inside of the array always is null, but other properties are correct.
https://i.stack.imgur.com/pmlh7.jpg
https://i.stack.imgur.com/qBDFQ.png
Logs form okhttp:
https://i.stack.imgur.com/I74Wp.png
Hi im using a node js server and retrofit
the login service is working perfectly and i've tested it on postman
i was sending only a message from my server but when i tried to send User model like this :
this problem of nullpointer exception arrives and it points on this line
i want to get the User to pass to the next interface which is profile and display some data
the login api was working perfectly until i did this change :
I was only displaying "message":"auth successful" and it was working
Your model class is not as per your response. I can see, you are adding user as object, but in response you are getting user as a list.
Replace
private User user
with
private List<User> user
and update respective methods too.
also add a check as below
if(response.body() != null)
String response = response.body().toSting()
I am making a POST request using Retrofit, call executes successfully on rest client. Also onResponse of call executes but in response body i am getting error
'unicode' object has no attribute 'items'.
What is the reason of this error?
I am creating and trying to save a table using active android but for some reason the object fails to save. The error that I get is
java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
Upon debugging the decompiled Model.class file I observed that an exception occurs while executing the following statement
(Please note that the below line is from the decompiled Model.class file of activeandroid)
long entityId1 = ((Model)e).getId().longValue();
It fails and the above said exception occurs. In the catch block I observe that for all non-primitive type fields the mId is non null, but for the field where the exception occurs the mId is null. I tried to search the web but could only find one line about mId.
ActiveAndroid automatically creates another auto-increment ID column. This is mId.
Then why does it fail to do so in this case. Does somebody have an idea? Thanks !!
OK I found the answer.
From codepath I found that
The problem is that This is because ActiveAndroid needs you to save
all objects separately. Before saving a tweet for example, be sure to
save the associated user object first. So when you have a tweet that
references a user be sure to user.save() before you call tweet.save()
since storing the user requires the local id to be set and assigned as
the foreign key for the tweet.
Thus I had to save my non primitive type object field first before saving the object.
I am attempting to use kSOAP 2 in my android application, and when I try to perform a particular webservice request, I end up getting thrown a "double ID" exception. I was able to find where this gets thrown in the kSOAP source code, it is in the SoapSerializationEnvelope class method public Object read() Here is an excerpt from that code showing the exception being thrown:
if (id != null) {
Object hlp = idMap.get(id);
if (hlp instanceof FwdRef) {
FwdRef f = (FwdRef) hlp;
do {
if (f.obj instanceof KvmSerializable)
((KvmSerializable) f.obj).setProperty(f.index, obj);
else
((Vector) f.obj).setElementAt(obj, f.index);
f = f.next;
} while (f != null);
} else if (hlp != null)
throw new RuntimeException("double ID");
idMap.put(id, obj);
}
I'm not at all sure what this exception is about, or how I can fix it. Anyone know what the deal with this exception is?
Thanks
Edit:
It should be noted that I am also using a SOAP webservice connection method in the iOS version of this application, and the same exact request does not have any problems.
New information:
Upon closer inspection, the problem seems to be resulting from the xml response I am getting containing a <diffgr:before> element, which has tables with the same ID as above. I think this is the cause of the problem, the other requests I have performed up to this point do not have that element in them, and do not have the exception. So to add to the question: can I stop the webservice from sending this block in its response, or get kSOAP to ignore it?
I was able to resolve this by removing the diffgr:before element the webservice was sending. I did that thanks to this post
well, I had the same problem too, but I had no diffgr:before in the xml response (And I can't change the webservice at all). Anyway, the problem was due to some empty values in the response. Using XOM
I managed to remove all empty elements and the it worked like charm. This is done by converting the response to string, loading it into nu.xom.Document element, remove the empty elements from the document and revert it back to InputStream for parsing with ksoap2