Error on any react native http call (android only - android

I'm developing a react native app using expo.
In IOS everything works perfectly, however in Android, any http call returns an error.
In my case, I use axios, so I only have a NETWORK ERROR, without further details, but even when fetching values ​​from remoteConfig I get an error.
The API is already published.
Does anyone have any suggestions?
Axios error
i hope the request works

Did you had the related permissions in the AndroidManifest ?
In the file android -> app -> src -> main -> AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.YOUR_APP_NAME">
<uses-permission android:name="android.permission.INTERNET" /> //This line
<application ... >
...
</application>
</manifest>

Related

How do I deal with the Agora exception "e/agora sdk cannot open log file for writing agorartm.log err=30"?

I use Agora as my RTM(Real Time Messaging) SDK, but after I set it up for Android develop, everything worked fine except for the problem that the RTMClientListener did not automatically update the messages received, and the debug console shows "e/agora sdk cannot open log file for writing agorartm.log err=30". Does anyone know how to fix this? Thanks in advance.
Try this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
The lines above allow Android application read and write permission of external files Add this into AndroidManifest.xml file - before application tag:
package="com.example.yourproject">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application...
Regarding the Agora Flutter app, the example app only works with low security mode Agora projects. Token or primary certificate activated projects won't work with the example app. Go to Agora dashboard, create a new project with low security level - only APP Id type. Then try the example app with the new App id copied from the dashboard of new project.

Flutter APK Build

Goo day friends! I am new to Flutter and I have been experimenting on fetching data via REST API. On Android Studio, everything works just fine, so I suppose there's nothing wrong with my code.
Things I did to make sure my code works:
1.) Run the code in android simulator;
2.) Run the code using real device (enabling USB Debugging).
And it works just fine.
But when I build an apk file out of it and install it on my device, it no longer makes the API call (or is unable to?). I made it so, when the app runs initState(), it waits for the data to be loaded. While the data is not yet available, a CircularProgressIndicator() takes the entire screen.
If I run the app via the installed apk file, it's just CircularProgressIndicator(). Meaning, no data is being loaded and displayed. But when I run the code in AndroidStudio, the data is shown..
I am using http package. I'm not sure what I'm doing wrong, or what I'm missing.
Other things to note: I did not change anything in my AndroidManifest file, and just followed all the steps on building apk file in Flutter through the official documentation.
Like alexsanderfr said, this is indeed most of the time being caused by missing
<uses-permission android:name="android.permission.INTERNET" />
You shouldn't need
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
for REST API.
In Flutter, when debugging you implicitly have access to internet, however in release builds, you need to explicitly declare this permission.
update1
Ensure you have the http-package added to your pubspec.yaml file and that it's properly indented with two spaces:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: ^0.12.0+4
Did you add the internet permission to the manifest? If you're accessing the internet from an Android app you need to add the internet permission over the application tag.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Cannot connect to Apollo GraphQL server on Android Release [react native]

httpURI = 'http://17.25.16.68:4000/graphql' //example
const httpLink = createHttpLink({ uri: httpURI });
const client = new ApolloClient({ link:httpLink, cache: new InMemoryCache() });
The connection works on debug mode, but when I run it on release, no connection is made.
Do I need to enable outgoing connections somewhere in the Android release config?
This is something that worked for me. apparently android pie doesn't allow network requests to URLs without https.
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
This file allowed android for reaching http requests.
In android/app/src/main/AndroidManifest.xml add the line below
<application
.
.
.
android:usesCleartextTraffic="true"
.
.
.
>
</application>

ionic android : when choose image from gallery the app crash

When I click on choose file(input="file") to choose an image from gallery , after select the image on android the app crash , and also on ios (iphone).
I already add the permissions on the androidmanifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
and still not working.
I was getting the same issue in iOS.
Try adding these data to info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>
For android can you share the logcat output.
How are you building the app, if you don't have Android Studio? Are you using phonegap?
If you have Android Studio, then a tool Monitor is pre installed with Android Studio. When you open Monitor, then the logs for the app can be seen
If phonegap is used, can u share the id, I can take a look if you want
If you only targeting images, I suggest to use the Cordova / Ionic Native plugins instead of using the file input. It will be easier and you will get more control in accessing images and its properties.
You can use either Camera plugin or Photo Library Plugin. You can use the requestAuthorization function to request the permissions from the user.
You may need to add permissions inside your config.xml. For example, as mentioned in the Camera Plugin Ionic's page
[Warning] Since IOS 10 the camera requires permissions to be placed in your config.xml add
<config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist"><string>You can take photos</string></config-file>
Please note that it is always the best idea to have all the permissions inside your config.xml file and not in the AndroidManifest.xml / info.plist, as it will always be added automatically once you add / run your build on the native platforms.

Is it possible to mock locations for release build type

I'd like to mock locations in release build type of Android app. I've created a special flavour "mockable" manifest in app/src/mockable/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
</manifest>
But it seems that Android lint blocks from using this permissions in release build type. For command:
./gradlew assembleRelease
I got output:
:app:lintVitalMockableRelease
/home/fr/app/src/mockable/AndroidManifest.xml:3: Error: Mock locations should only be requested in a debug-specific manifest file (typically src/debug/AndroidManifest.xml) [MockLocation]
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explanation for issues of type "MockLocation":
Using a mock location provider (by requiring the permission
android.permission.ACCESS_MOCK_LOCATION) should only be done in debug
builds. In Gradle projects, that means you should only request this
permission in a debug source set specific manifest file.
To fix this, create a new manifest file in the debug folder and move the
<uses-permission> element there. A typical path to a debug manifest
override file in a Gradle project is src/debug/AndroidManifest.xml.
1 errors, 0 warnings
Is it possible to generate release app with location mocking permission?
Disable the MockLocation lint check for that particular permission, i.e.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"
tools:ignore="MockLocation" />
</manifest>
(Refer to http://tools.android.com/tips/lint-checks)
The only solution I know for sure is to let lint report errors but don't let that abort the build process:
To enable that just add
lintOptions {
abortOnError false
}
inside the android block.
You will still get lint errors and warnings but the build will continue.
I am not sure if you can put that inside the flavor definition or use a custom buildType for that. I have no project where I could test that.
This is a caution. If you want a user to "mock location" then the user must enable mock locations in Android.
A production release is definitely possible, I have done this. You need to prompt the user to allow for "Mock Locations" like a developer/debug would.

Categories

Resources