Skip to content
Advertisement

“Value <br of type java.lang.String cannot be converted to JSONObject" – Android Studio

So I am using Android Studio (Java), and I have to communicate with a website that I made using Apache (xampp). I put in a json object 3 variables. Two of them are strings and the other is a signature I made using the code on the website – https://developer.android.com/training/articles/keystore. The error “Value <br of type java.lang. String cannot be converted to JSONObject” shows when the jsonObjectRequest is made because of the signature variable (I say this because when I take it out, the code works, but I really need to send the signature). The signature is in byte so I tried to put it in a string variable but that didn’t work either. I don’t believe the error is in the PHP code. How can I fix this?

This is my code:

Android Studio:

JavaScript

I decided to put part of the php code. PHP:

JavaScript

Advertisement

Answer

I found the solution, the problem really was because of the format of the key and signature.

Android Studio:

JavaScript

PHP:

JavaScript

Thank you to everyone who tried to help!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement