google-translate-open-api icon indicating copy to clipboard operation
google-translate-open-api copied to clipboard

Not Working When After Apps Build to APK

Open YudeMgoy opened this issue 5 years ago • 27 comments

Works fine when debugging but after build its not working anymore

YudeMgoy avatar Jul 03 '20 07:07 YudeMgoy

Can you print some log information about the web after you package it into apk?

hua1995116 avatar Jul 03 '20 10:07 hua1995116

I catch the error and it says error with status code 403

YudeMgoy avatar Jul 03 '20 12:07 YudeMgoy

Getting a CORS error when running in electron. Could be the same reason

sittingbool avatar Jul 04 '20 17:07 sittingbool

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
});

hua1995116 avatar Jul 05 '20 03:07 hua1995116

Here's a demo of the repo. https://github.com/hua1995116/google-translate-open-api-demo/tree/master/electron

hua1995116 avatar Jul 05 '20 03:07 hua1995116

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 avatar Jul 06 '20 06:07 sittingbool

@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

hua1995116 avatar Jul 06 '20 06:07 hua1995116

its still error in my app

YudeMgoy avatar Jul 07 '20 13:07 YudeMgoy

Can you show your code? Then show more error details

hua1995116 avatar Jul 07 '20 13:07 hua1995116

IMG_20200708_090200

Its my code, but i have no idea what's the error message. I try with try and catch but it return nothing

YudeMgoy avatar Jul 09 '20 06:07 YudeMgoy

I have same issue, API returns Request failed with status code 403 on React Native Android release build. Screen Shot 2020-07-09 at 6 09 29 PM

phuongpt avatar Jul 09 '20 10:07 phuongpt

I have same issue, API returns Request failed with status code 403 on React Native Android release build. Screen Shot 2020-07-09 at 6 09 29 PM

That's same as me, i use react native too and also have that error

YudeMgoy avatar Jul 09 '20 13:07 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

hua1995116 avatar Jul 10 '20 07:07 hua1995116

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?

YudeMgoy avatar Jul 10 '20 09:07 YudeMgoy

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.

hua1995116 avatar Jul 10 '20 09:07 hua1995116

@YudeMgoy Are you using my apk to access properly?

hua1995116 avatar Jul 10 '20 10:07 hua1995116

@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

YudeMgoy avatar Jul 10 '20 14:07 YudeMgoy

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!

hua1995116 avatar Jul 10 '20 14:07 hua1995116

Did you solve the problem by changing the domain extension? @YudeMgoy

hua1995116 avatar Jul 11 '20 12:07 hua1995116

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.

YudeMgoy avatar Jul 12 '20 09:07 YudeMgoy

Its strange, my first time try is there is error code 503, but now its doesnt give me anything even the code wont run

YudeMgoy avatar Jul 12 '20 09:07 YudeMgoy

@hua1995116 I guess your apk was built in debug mode. I built my app with your code by Appcenter in release mode Screenshot_20200713-110322

phuongpt avatar Jul 13 '20 04:07 phuongpt

Same here. I get release apk and get the same error.

OSD-LuanNguyen avatar Aug 25 '20 02:08 OSD-LuanNguyen

Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool

hua1995116 avatar Oct 04 '20 06:10 hua1995116

Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool

Yap it still exist on my app

YudeMgoy avatar Oct 04 '20 15:10 YudeMgoy

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 image

Does this problem still exist? @OSD-LuanNguyen @YudeMgoy @sittingbool

Yap it still exist on my app

hua1995116 avatar Oct 05 '20 06:10 hua1995116

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 image

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

YudeMgoy avatar Oct 07 '20 11:10 YudeMgoy