ionic android : when choose image from gallery the app crash - android

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.

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.

React-Native 0.63 not able to access Device Storage images in Android 10

I am using React Native 0.63. I wanted to display images in a FlatList from my phone's device storage and was using <Image/> for the renderItem prop of FlatList.
Using the source prop, I added a uri key but I am still not able to see the images. The image tiles are being generated in the FlatList and I am able to see the thin scrollbar on the right when I try to scroll over the list.
This is what I am doing to display the image. (The uri used here is of an image which I got from the CameraRoll.getPhotos() API)
<Image
source={{ uri: 'file:///storage/emulated/0/Pictures/Twitter/20201019_160855.jpg'}}
style={{ height: 100, width: 100 }}
/>
I have made sure about the following:
Allowed READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions for the application.
Added file:// prefix to the file.
Made sure source={{ uri: ... }} in <Image/> works for external links, tried using Google logo, random jpegs from the internet.
Another thing which I noticed is, I am using Samsung phone with Android 10 on my device where I am facing this issue. I tried running this on the Google Nexus 5 Android Emulator which also runs on Android 10 and works perfectly fine (By this, I mean I am able to access the emulator's device storage and not using the exact same uri specified above).
UPDATE: Tried compiling the application on Android 7, the above thing is working fine. Any issue with the the SDK Versions?
Are you getting a permission denied error?
This might be helpful:
https://github.com/react-native-image-picker/react-native-image-picker/issues/1259
Something to try adding:
android:requestLegacyExternalStorage="true"
... to the tag in your AndroidManifest.xml.
Warning:
From May 5 2021 onwards:
Play Store will not accept this implementation and remove all apps using it except if the app functionally really requires it and it needs to be requested.
The implementation will need to use Scoped Storage.
Are the images appearing on the emulator correctly?
If the issue is only on your device, you will want to check you've added
android.permission.READ_EXTERNAL_STORAGE to your AndroidManifest.xml and requested perission to use file storage
See: Usage - react-native CameraRoll
This can be helpful: https://github.com/react-native-image-picker/react-native-image-picker/issues/1259
In manifest
android:requestLegacyExternalStorage="true"
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="true"
android:theme="#style/AppTheme"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true">
build.gradle
// camera
compileSdkVersion = 29
I Found Storage Permission wasn't working in the Samsung Phone
so i added following in the
android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
More Importantly This fixed my Issue :
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
then check for the Permission as regular and it will work
My Config for the React-native APP
"react": "18.1.0",
"react-native": "0.70.6",
buildToolsVersion = "31.0.0"
minSdkVersion = 22
compileSdkVersion = 33
targetSdkVersion = 33
This Worked in My case 👍👍
Happy Hacking 😂

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" />

Myo android first connection

I am very new to android. I am trying to follow this Myo android tutorial
But I am facing a lot of problems since I don't know a lot about android.
My first problem is with placing the sdk , I downloaded it, and it is written that I have to add the SDK as a dependency in my build.gradle file.
When I explored my project, I found 2 build.gradle files as in the image:
So should I add it in which one ?
And how should I add it as an absolute path so I can use the SDK on all devices without changing the path ?
And then they asked me to add these permissions, but where should I add them?
// Required for communicating with the Myo device
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
// Required for sending usage data to Thalmic Labs
<uses-permission android:name="android.permission.INTERNET" />
Q1:So should I add it in which one ?
A:You should add it in the "Module:app" one.
Q2:how should I add it as an absolute path so I can use the SDK on all devices without changing the path ?
A:The path of the SDK doesn't relate to the result,the SDK will be wrapped up in the apk,so don't worry about it.
Q3:Where should I add them (permissions)
A:Add them in AndroidManifest.xml.

How can you read from the public download directory from unity on an android

I'm trying to read from a file in Unity that I've written to the Downloads folder in Android.
I'm writing the file natively with another apk and I've copied the url that I wrote to: "/storage/emulated/0/Download/file" but when I try File.Exists(thatUrl) it's returning false.
So apparently the permission: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> means something different in Unity than it does it the native Android SDK. Having that permission allows you to read from the INTERNAL storage as well as the external.

Categories

Resources