requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission() - flutter

when using Image-Picker package and run ,this exception is showing . image is not shows in the container after taking the image..

Beside needing to add WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE to your android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.yyy">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
...
</manifest>
You also need Runtime Request Permission, by using permission_handler package:
import 'package:simple_permissions/simple_permissions.dart';
PermissionStatus permissionResult = await SimplePermissions.requestPermission(Permission. WriteExternalStorage);
if (permissionResult == PermissionStatus.authorized){
// code of read or write file in external storage (SD card)
}
Note:
when running SimplePermissions.requestPermission for the First Timeļ¼Œ app will pop up a window, you MUST click ALLOW:
to give permission.
If you already clicked DENY, then uninstall debug app and re-debug it to install and fix this -> trigger the popup window and give you chance to click ALLOW.

Related

What Can I Do if appid and cpid Cannot Be Found During an HMS Core SDK Integration Test?

After I integrated the HMS Core SDK and call the api in the SDK,it failed.And two errors are reported in the log,the first of which is that appid and cpid cannot be found, and the other is the result code 907135000 is reported.
The following error information is recorded in the logs:
E/HMSSDK_AGCUtils: In getMetaDataAppId, Failed to read meta data for the AppID.
E/HMSSDK_AGCUtils: Get client/app_id failed: java.io.FileNotFoundException: agconnect-services.json
E/HMSSDK_AGCUtils: The client/app_id is null.
E/SecurityResourcesReader: KEY is null return def directly
I/HMSSDK_AGCUtils: In getMetaDataCpId, Failed to read meta data for the CpId.
E/HMSSDK_AGCUtils: Get client/cp_id failed: java.io.FileNotFoundException: agconnect-services.json
E/HMSSDK_AGCUtils: The client/cp_id is null.
I/HMSSDK_HmsClient: receive msg status_code:1, error_code 907135000, api_name:core.getNoticeIntent, app_id:|, pkg_name:com.appservicetest.huawei, session_id:*, transaction_id:000000000Intent20201105190645844381286, resolution:null
Copy the agconnect-services.json file to the app directory of your project, as shown in the following figure.
Check whether applicationId in the app-level build.gradle file shares the same package name as that configured in AppGallery Connect. The name is case sensitive.
Go to buildscript > dependencies in the project-level build.gradle file and check whether the AppGallery Connect plug-in configuration has been added.
Sample code:
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
...
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
}
}
Check whether the following configuration has been added to the app-level build.gradle file:
apply plugin: 'com.huawei.agconnect'
Please note that this configuration must be added to the next line of apply plugin: 'com.android.application. Otherwise, an error may occur.
If you are releasing a package on multiple platforms, the preceding method may not solve the problem. In this case, you can try this method:
Add the JSON file to the app directory and define appid and cpid in manifest.json by adding the following code:
<meta-data
android:name="com.huawei.hms.client.appid"
<!-- Replace xxx with the actual app ID, which can be obtained on the App information page. --> -->
android:value="appid=xxx">
</meta-data>
<!-- Replace xxx with the actual payment ID, which can be obtained from the app's IAP information. --> -->
<meta-data
android:name="com.huawei.hms.client.cpid"
android:value="cpid=xxx">
</meta-data>
Query cpid in the agconnect-services.json file.

After upload the Andriod app to APkPure the system keeps show Error 10003 In

I uploaded a test app to APkPure. After the upload and refresh the page APkPure shows this error message with no other description :
"The version your uploaded didn't pass the upload verification. Error 10003. Please try again."
I tried many times with no luck. Does anyone know what this error means?
The package name of your apk is different from the package name you typed on APkPure.
Try and have a uniform package name. Ave Maria.
In your file manifest of the app you watch
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="name_package">
you must copy "name_package" and to place in apkpure.

How to open pdf file in the app using Flutter

I am using flutter_pdfview which is version ^1.0.0+10 to open a PDF file in flutter apps. When my app is in debug mode, there is no error. After I build the app the PDF file cannot open in apps. My app will crash and close suddenly. I have open the permission in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
How can solve this error?
First you need to create a proguard-rules.pro file at /android/app/ inside there write like this:
#Flutter Wrapper
-keep class com.shockwave.**
Then at /android/app/build.gradle add this:
buildTypes {
release {
signingConfig signingConfigs.release
**minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'**
}
}
I have this problem only on android but when the app is on production. To fix this I add the permission handler plugin and change the path. Also and very important was add the extension ".pdf" to file after download but before read.
final filename = url.substring(url.lastIndexOf("/") + 1);
var request = await HttpClient().getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
String dir = (await getExternalStorageDirectory()).path;
File file = new File('$dir/$filename.pdf');
await file.writeAsBytes(bytes);
pathPDF = file.path;
return file;
If you are running debug on an emulator and then release on a real device, this might be your problem:
PdfViewPage(path: '/storage/emulated/0/Download/$pdfName')));
Even if it isn't causing the crash it is a bad idea to hardcode download path like you've done. Different devices can have downloads in different locations. You can use downloads_path_provider to find where downloads is located.
Also, beside declaring the permissions needed in the Manifest you should also ask user for permission and handle the situation if the user doesn't give permission. For that task I suggest using permission_handler.

Adding firebase_auth package, Android simulation - app won't start

my goal is to get the example app "working" (counter) with this import line included:
import 'package:firebase_auth/firebase_auth.dart';
I am using VS Code.
I verify the app loads fine w/o this line
I add this line (yes, I am not using it)
I add firebase_auth: '^0.8.0+1' to dependencies in pubspace.yaml
I add apply plugin: 'com.google.gms.google-services' to the bottom of android/app/build.gradle
I add classpath 'com.google.gms:google-services:3.2.1' w/in dependencies in file android/build.gradle
I debug. Build works, no errors. App does not come up on simulator. My "biggest" frustration is I am not given any feedback on what I did wrong.
Q: how do we debug these type of challenges with no feedback?
Q: the reason I stripped flutter <-> firebase to this simple example is because when I went through the examples, I couldn't get the app to load when I added firebase.
Is it completely obvious what I am doing wrong?

ionic platform add android- Package name must look like: com.company.Name

Im getting started in developing ionic app, I followed the guide in http://ionicframework.com/docs/guide/installation.html
just in case: the command "ionic platform add ios" works and i have android sdk installed.
when typing the command "ionic platform add android" i get this error:
Adding android project...
/Users/LihaiMac/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin/node_modules/q/q.js:126
throw e;
^
Package name must look like: com.company.Name
Error: /Users/LihaiMac/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin/create: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1008:16)
at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
I tried searching an answer in other related posts, but not successful..
I'll appreciate any help in solving my problem..
What mladen5 said is correct. You need to go to the config.xml of your Cordova/Phonegap project and edit the id to meet the package name expectations.
The name can be found in the ID property and is "com.mydomainhere.appnamehere" in the example config below:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.mydomainhere.appnamehere" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Awesome app</name>
<description>
The worlds most awesome app
</description>
<author email="your#email.com" href="http://www.anurlhere.com">
Author name
</author>
<content src="index.html" />
<access origin="*" />
</widget>
"Package name must look like: com.company.Name" that error is very helpful. You have package name that is invalid, probably starts with number.
Android package rules:
The first character after a period must not be a number
The first character must be a letter or underscore
Usually the app id is your company's reserved Internet domain name.
The app id must consist of letters, numbers, and underscores.
The best way to do it is when you're creating a new app. The Ionic command line interface(CLI) supports two options to do that the right way:
You can also app and package name define using command line interface(CLI) creation you project time like this bellow.
ionic start MyNewApp blank --appname MyNewApp --id com.ionicbyrequest.mynewapp
MyNewApp is my project app name.
Simple, no ? Now when you deploy to stores your id will be unique.
I had the same problem with Ionic a few weeks ago. The problem can be fixed by editing config.xml.
Find the line that starts with
The syntax inside id="" must be com.company.(company name)
ID should be without dashes, just words separated with dots: word.word.word
In your config.xml give the package name according to your project package name
Give widget id in your config.xml as com.test.testapp