You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Gemini 1.5 Pro Error: "Something went wrong while trying to deserialize a response from the server." #160
I get this error very, very often. I wait about 15 seconds and repeat the prompt until I get a normal response. The prompt is not in English. This wastes a lot of time and I don't know how to fix it. Is there a way to handle errors? The model returns them to normal text that I have to parse. So far I have received over x3 types of different errors from Gemini 1.5 Pro.
BILLING from google.ai.generativelanguage.v1beta.GenerativeService.GenerateContent
Gemini requests are currently being billed to me. The problem is that I get an error from the library and no result.
Please tell me what to do? This library has a serialization error. I repeatedly repeat the request until I get an answer that does not have an error and in this way insanely large amounts are charged. Is there a way to not charge these errors? If not, in this case this library is not appropriate to use because it generates billing that is without any content.
For example, here is the following error:
I think the issue may be because you are subclassing FunctionDeclaration. This is not the intended use. Does this error also occur if you use the defineFunction methods?
relatedly, if you happen to be able to pull the text of one of these responses that fails to parse that would help debugging immensely. If you're in android studio you can use the network inspector in App Inspection to accomplish this.
I made a change to the code but it didn't help. It keeps giving the same error. After a few tries it manages to return a correct result, but this is not a good idea because it is charged.
relatedly, if you happen to be able to pull the text of one of these responses that fails to parse that would help debugging immensely. If you're in android studio you can use the network inspector in App Inspection to accomplish this.
I can give you the prompt, but I don't want it here publicly. Maybe an email. Note that the prompt is in Bulgarian and this may be a problem. However, the fact is that the same prompt has no problem in AI Studio
That would allow us to see what gets send and what you get back. As @davidmotson said, structure matters rather than content, so you can edit out the values.
That would allow us to see what gets send and what you get back. As @davidmotson said, structure matters rather than content, so you can edit out the values.
Temporarily stopped the Gemini API
I've also temporarily stopped the Gemini API for obvious reasons and can't give you a result from Network Inspector, but I've emailed everything I need and described the problem pretty well.
I hope you fix the error as soon as possible!
I have used type safe text for TextPart(val text: String)
I have no null strings passed
I also emailed the prompt to @davidmotson which shows that everything is normal.
here is the code snippet which appears to be null safe (prompt):
Activity
karloti commentedon May 30, 2024
BILLING from google.ai.generativelanguage.v1beta.GenerativeService.GenerateContent
Gemini requests are currently being billed to me. The problem is that I get an error from the library and no result.
Please tell me what to do? This library has a serialization error. I repeatedly repeat the request until I get an answer that does not have an error and in this way insanely large amounts are charged. Is there a way to not charge these errors? If not, in this case this library is not appropriate to use because it generates billing that is without any content.
For example, here is the following error:
dump.txt
rlazo commentedon May 30, 2024
Hey @karloti could you share the prompt you are using that's triggering the deserialization issue for debugging?
karloti commentedon May 30, 2024
Hello,
thanks for your quick reply.
I think this is where the problem comes from. I'm thinking of replacing it with a String scheme
davidmotson commentedon May 30, 2024
I think the issue may be because you are subclassing FunctionDeclaration. This is not the intended use. Does this error also occur if you use the defineFunction methods?
rlazo commentedon May 30, 2024
Sounds like a possibility, since the trace points to that line
that being said, it should absolutely not fail deserializing. The model is not returning a value that we were expecting.
davidmotson commentedon May 30, 2024
relatedly, if you happen to be able to pull the text of one of these responses that fails to parse that would help debugging immensely. If you're in android studio you can use the network inspector in App Inspection to accomplish this.
karloti commentedon May 30, 2024
I made a change to the code but it didn't help. It keeps giving the same error. After a few tries it manages to return a correct result, but this is not a good idea because it is charged.
karloti commentedon May 30, 2024
I can give you the prompt, but I don't want it here publicly. Maybe an email. Note that the prompt is in Bulgarian and this may be a problem. However, the fact is that the same prompt has no problem in AI Studio
davidmotson commentedon May 30, 2024
Actually, the response is more important, Feel free to remove any strings you like from it, the structure is whats important.
If you'd prefer to email it to me, you can email it to davidmotson@google.com
rlazo commentedon May 30, 2024
Alternatively, you could record request/responses send to the server using https://developer.android.com/studio/debug/network-profiler
That would allow us to see what gets send and what you get back. As @davidmotson said, structure matters rather than content, so you can edit out the values.
karloti commentedon May 31, 2024
I forked
generative-ai-android.gitI suspect that the error is caused by the serialization of the returned list of candidates.
karloti commentedon May 31, 2024
Temporarily stopped the Gemini API
I've also temporarily stopped the Gemini API for obvious reasons and can't give you a result from Network Inspector, but I've emailed everything I need and described the problem pretty well.
I hope you fix the error as soon as possible!
I have used type safe text for TextPart(val text: String)
I have no null strings passed
I also emailed the prompt to @davidmotson which shows that everything is normal.
here is the code snippet which appears to be null safe (prompt):
karloti commentedon Jun 5, 2024
This bug will be fixed in v0.8.0
I have already tested the latest update and the bug is caught.
Thanks to David for fixing this.
karloti commentedon Jun 8, 2024
@davidmotson
https://drive.google.com/drive/folders/10S8eA3nXlkxUjqlK9EuIptzDMF7WQJf1?usp=sharing
rlazo commentedon Jun 12, 2024
Seems like this is not the same issue as the original one. Please create a new issue to track it separately. Thanks!
New version 0.8.0 has been published, including the fix to the original issue.