google-translate-open-api
google-translate-open-api copied to clipboard
Not Working When After Apps Build to APK
Works fine when debugging but after build its not working anymore
Can you print some log information about the web after you package it into apk?
I catch the error and it says error with status code 403
Getting a CORS error when running in electron. Could be the same reason
I found a problem with the user-agent, I have now upgraded to 1.3.4 , which is fine. Using isUserAgent: false to solve the problem, I tested in [email protected] It works well. I think it might be the same problem in apps.
const result = await translate([`I'm fine. And you?`,`I'm ok.`], {
tld: "cn",
to: "zh-CN",
isUserAgent: false
});
Here's a demo of the repo. https://github.com/hua1995116/google-translate-open-api-demo/tree/master/electron
Hi, I could solve it with that fix: I set electrons web security to false in a previous hotfix and it gave me that userAgent error. Now that you fixed that as well it works like a charm but I still have to disable electrons websecurity in development mode because it acts as a server and requests want to be originated from localhost. but that seems to be an unavoidable problem with electron.
@sittingbool You don't need to close the SCP. You can open a separate whitelist. You can look at this case. https://github.com/hua1995116/google-translate-open-api-demo/blob/master/electron/index.html#L6-L7
its still error in my app
Can you show your code? Then show more error details

Its my code, but i have no idea what's the error message. I try with try and catch but it return nothing
I have same issue, API returns Request failed with status code 403 on React Native Android release build.

I have same issue, API returns
Request failed with status code 403on React Native Android release build.
That's same as me, i use react native too and also have that error
Since I haven't developed an RN, I tested it in my spare time, and here's the code I tested, which is in both dev and release are working fine. Can you provide me with more and more complete information, as I have no way to troubleshoot it at this time?
Here are my code.
https://github.com/hua1995116/google-translate-open-api-demo/blob/master/react-native/reactNativeProject/App.js
This is Android release APK.
app-release.apk.zip
@phuongpt @YudeMgoy
Since I haven't developed an RN, I tested it in my spare time, and here's the code I tested, which is in both dev and release are working fine. Can you provide me with more and more complete information, as I have no way to troubleshoot it at this time? Here are my code. https://github.com/hua1995116/google-translate-open-api-demo/blob/master/react-native/reactNativeProject/App.js This is Android release APK. app-release.apk.zip @phuongpt @YudeMgoy
Is tld must be filled?
https://github.com/hua1995116/google-translate-open-api/blob/master/src/translate.ts#L28
No, There will be restrictions on accessing some sites in China, so adopted the use of cn and defaulted to com.
@YudeMgoy Are you using my apk to access properly?
@YudeMgoy Are you using my apk to access properly?
yes, i have tried your apk and i see the code is same the differences just at the language code and tld. Could you try for me use language code "id" instead
So maybe it's because of the regional restrictions on the different domains of google. I upgraded to version 1.3.5 and then tried using the Google Translate suffix for your current region. You can try.
Best wishes!
Did you solve the problem by changing the domain extension? @YudeMgoy
I try with default code you give, but its still not solved yet. Nothing error but the code wont run i think, my state variable still with default value.
Its strange, my first time try is there is error code 503, but now its doesnt give me anything even the code wont run
@hua1995116 I guess your apk was built in debug mode. I built my app with your code by Appcenter in release mode

Same here. I get release apk and get the same error.
Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool
Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool
Yap it still exist on my app
I used xcode to test again, but still can't reproduce your error. Do you think my configuration is consistent with yours? I did not reproduce this error on iphone x and iphone 8 plus. The demo address is https://github.com/hua1995116/google-translate-open-api-demo/tree/master/react-native/reactNativeProject

Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool
Yap it still exist on my app
I used xcode to test again, but still can't reproduce your error. Do you think my configuration is consistent with yours? I did not reproduce this error on iphone x and iphone 8 plus. The demo address is https://github.com/hua1995116/google-translate-open-api-demo/tree/master/react-native/reactNativeProject
Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool
Yap it still exist on my app
Maybe you can try on android project, then build the app first, i mean a full build not debuging build