Network error on android signed apk
See original GitHub issueIntended outcome:
The queries should be executed as expected, without raising network errors.
Actual outcome:
There are happening network errors when executing the queries, even with a valid network connection.
How to reproduce the issue:
- Setup apollo on an RN app, with the following config:
import {
ApolloLink,
ApolloClient,
InMemoryCache,
createHttpLink,
} from "@apollo/client";
import { setContext } from "@apollo/client/link/context";
import { buildSentryErrorLink } from "apollo-sentry-helper";
import getApiUri from "./getApiUri";
import { getUserJWT } from "~/utils/getUserJWT";
export const API_URI = getApiUri();
const httpLink = createHttpLink({ uri: API_URI });
const authLink = setContext(async (_req, { headers }) => {
const token = await getUserJWT();
return {
...headers,
headers: {
authorization: token ? `Bearer ${token}` : null,
},
};
});
const sentryErrorLink = buildSentryErrorLink();
const link = ApolloLink.from([
sentryErrorLink,
authLink,
httpLink,
]);
const cache = new InMemoryCache({
typePolicies: {
Query: {
fields: {
viewer: {
merge: (existing, incoming, opts) => (
opts.mergeObjects(existing, incoming)
),
},
},
},
},
});
const apolloClient = new ApolloClient({
cache,
link,
});
export default apolloClient;
- Executes a query on an Android signed apk
Versions System: OS: macOS 10.15.6 Binaries: Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm Browsers: Chrome: 85.0.4183.121 Safari: 14.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Signed android apk - network problem - Stack Overflow
I have signed my app using netbeans and exported it, uploaded to android market, all fine. On install of the app, it tells...
Read more >NetworkException | Android Developers
Error code indicating the device was not connected to any network. Constant Value: 2. public static final int ERROR_NETWORK_CHANGED.
Read more >How To Fix APKPure App Network Connection Error Android
APKPure # NetworkError # Android #InternetError ... To Fix APKPure App Network Connection Error Android - Fix APKPure App Internet Connection.
Read more >How To Fix APKPure App Network Connection Error Android ...
APKPure # NetworkError #InternetError #Internet #Network #ConnectionerrorFix APKPure Network / Internet Connection Problem in Android & Ios ...
Read more >Resolving Network Error in Android app development - QED42
If you access the API over HTTPS with a domain name and receive a “Network Error”. Try checking the access logs and error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am getting the same error. All my queries work well in iOS but give me a network request failed error in Android. Some other SO and GitHub solutions suggested that I shouldn’t be using
localhost
for myuri
and should use my computer’s IP address. But I am already not using localhost.The uri I am using is the Graphql Endpoint POST url from my Hasura console. I am testing by using an Android emulator from the Android Studio and not on a real device. What else could I try?
I also tried adding this
android:usesCleartextTraffic="true"
to AndroidManifest.xml file but it doesn’t make a difference.I’m also having the same problem. The error happens randomly, something the queries fail and sometimes they don’t. It seems that it is more likely to happen in the first query that is executed right after opening the app.
Also important to note that we’re using HTTPS.