Airsaid / AndroidLocalizePlugin

:earth_asia: Android localization plugin. supports multiple languages and multiple translators.
https://plugins.jetbrains.com/plugin/11174-androidlocalize
Apache License 2.0
594 stars 92 forks source link

ava.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ #162

Open W-quan opened 5 months ago

W-quan commented 5 months ago

Please ensure you have given all the following requested information in your report.

Please select the affected platforms

Please select the translator to use

Version of Plugin and IDE

Issue details

Translation failure: Failed to translate "CP Reward" from Auto to Indonesian with error: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

KovshefulCoder commented 5 months ago

Same error, maybe additional logs might be saved in some file

hersheyc2pgroup commented 4 months ago

The logs are written to \AppData\Local\Google\AndroidStudio[your version]\log\idea.log. It seems that Google Translate restricts the IP due to unusual traffic. See the attached error when opening https://www.google.com/sorry/index# in my browser. image

W-quan commented 4 months ago
2024-07-10 20:26:59,373 [99003844]   WARN - #com.airsaid.localization.task.TranslateTask - Failed to translate "if you delete this moment, the comments and likes will also disappear." from Auto to Ukrainian with error: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
com.airsaid.localization.translate.TranslationException: Failed to translate "if you delete this moment, the comments and likes will also disappear." from Auto to Ukrainian with error: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.airsaid.localization.translate.AbstractTranslator.doTranslate(AbstractTranslator.java:76)
    at com.airsaid.localization.translate.services.TranslatorService.doTranslate(TranslatorService.java:120)
    at com.airsaid.localization.task.TranslateTask.doTranslate(TranslateTask.java:205)
    at com.airsaid.localization.task.TranslateTask.doTranslate(TranslateTask.java:170)
    at com.airsaid.localization.task.TranslateTask.run(TranslateTask.java:126)
    at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:477)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:528)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:250)
    at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:100)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:46)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
    at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:100)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:250)
    at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:500)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:397)
    at com.google.gson.Gson.fromJson(Gson.java:1227)
    at com.google.gson.Gson.fromJson(Gson.java:1137)
    at com.google.gson.Gson.fromJson(Gson.java:1047)
    at com.google.gson.Gson.fromJson(Gson.java:982)
    at com.airsaid.localization.translate.impl.google.GoogleTranslator.parsingResult(GoogleTranslator.java:93)
    at com.airsaid.localization.translate.AbstractTranslator.lambda$doTranslate$1(AbstractTranslator.java:71)
    at com.intellij.util.io.HttpRequests.doProcess(HttpRequests.java:529)
    at com.intellij.util.io.HttpRequests.process(HttpRequests.java:511)
    at com.intellij.util.io.HttpRequests$RequestBuilderImpl.connect(HttpRequests.java:340)
    at com.airsaid.localization.translate.AbstractTranslator.doTranslate(AbstractTranslator.java:55)
    ... 28 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:393)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:386)
    ... 38 more
hersheyc2pgroup commented 3 months ago

Using a paid Google API key solved this issue for me. See in the readme that the default translation engine is not stable. Readme FAQ #2