How to download files/images etc. in flutter webview? - flutter

I am using the flutter_webview_pro plugin for webview in my flutter application, but I am not able to download file/image etc. in the that application.
I added following in androidmanifest.xml file
<provider
android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
android:authorities="${applicationId}.flutter_downloader.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
and also added the permission in the same file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Related

What's wrong with this code.When I clean the flutter dependencies and run flutter pub get then I got this error. What I have to do to fixed this error

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bpls">
<uses-permission android:name="android.permission.INTERNET"/>
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:label="bpls"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Error parsing LocalFile: 'C:\Users\prashant\Desktop\bpls\android\app\src\main\AndroidManifest.xml' Please ensure that the android manifest is a valid XML document and try again.
You Just Need to Replace this with your AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bpls">
<uses-permission android:name="android.permission.INTERNET"/>
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:label="bpls"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

how to manually update add android:exported in the flutter package

the application cannot be uploaded to the playstore with the reason that it must define android:exported, even though I have defined it in the flutterProject/android/app/src/main/AndroidManifest.xml, but the error remains the same, I suspect because the package I am using is old school,
I want to update it manually but the manifest is just like below
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.onesignal.flutter">
</manifest>
how to solve it?
Simply do like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<application
android:label="App"
android:name="${applicationName}"
android:icon="#mipmap/launcher_icon">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="#string/facebook_client_token"/>
<activity
android:name=".MainActivity"
android:exported="true" //here ------
you need to add this in Activity Tag
(Must Add Launcher Activity : android:exported="true")

Flutter : firebasemessaging.FlutterFirebaseMessagingService: Targeting S+ (version 31 and above) requires that an explicit value

I want run a existing project. It's fully run on under Android 12 but when I going to run a samsung phone which version is Android 12. Then I get this type of error.
Error :
✓ Built build/app/outputs/flutter-apk/app-release.apk (104.1MB).
Installing build/app/outputs/flutter-apk/app.apk... 3.3s
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install /Users/abir/Documents/Office
Work/appName-App-Old-Version/build/app/outputs/flutter-apk/app.apk: Failure
[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI:
/data/app/vmdl2043233695.tmp/base.apk (at Binary XML file line #124):
io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: Targeting S+
(version 31 and above) requires that an explicit value for android:exported be
defined when intent filters are present]
Error running application on SM G781B.
Here is my AndroidManifest.xml file :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="care.appname.health">
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:label="appname"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
I tried android:exported="true" true and false also. But nothing is worked. How can I solve this ?
Add service to application, it's work for me.
<service android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService" android:exported="true"/>

API not working/http error SocketException: Failed host lookup in Release Build(working in debug mode) For Flutter

Getting Some Of Notes Regarding path_provider-1.5.1 and API not working which I integrated through http/dio in Release Build(working in debug mode) For Flutter.
Note:
/home/webelightpc/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.5.1/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java
uses or overrides a deprecated API. Note: Recompile with
-Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note:
Recompile with -Xlint:deprecation for details.
According to https://github.com/flutter/flutter/issues/27883
It's strange that without adding permission in AndroidManifest.xml it'll work in debug but in release modeany API request will not work, solutions is as simple as below...
just add permission like this
<uses-permission android:name="android.permission.INTERNET" />
in your app's android/app/src/main/AndroidManifest.xml
For those people who are new in flutter,here is the full demo. you have to add permission above "Application" tag
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reprecinct.app.reprecinct">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="your app label"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

Overwrite manifest (themes)

I have a project that has 3 themes (support,crm,sales), when I compile a version, I have to change the tiapp.xml:
id (com.website.[support/crm/sales])
name (Website [Support/CRM/Sales])
android manifest
My question is: there are any way to replace or merge the android manifest or some parts of tiapp.xml file:
uses-permission android:name="com.website[support/crm/sales].permission.MAPS_RECEIVE"
permission android:name="com.website.[support/crm/sales].permission.MAPS_RECEIVE"
activity android:name=".Website[Support/CRM/Sales]Activity"
This is my manifest:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>14</tool-api-level>
<manifest>
<uses-sdk android:maxSdkVersion="23"
android:minSdkVersion="14" android:targetSdkVersion="23"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-permission android:name="com.website.[support/crm/sales].permission.MAPS_RECEIVE"/>
<permission
android:name="com.website.[support/crm/sales].permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application android:debuggable="true"
android:largeHeap="true" android:theme="#style/Theme.MyTheme">
<meta-data
android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyDcN-CWFqg4-Ai4Es10E0sSDmJ7seo4XAg"/>
<activity
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:name=".Website[Support/CRM/Sales]Activity" android:screenOrientation="landscape"/>
</application>
<supports-screens android:anyDensity="true"/>
</manifest>
</android>
The main/default icons, I've to replace them manually, while this feature isn't added: https://jira.appcelerator.org/browse/ALOY-1318
Unfortunately tiapp.xml is amongst the few things you cannot theme through Alloy yet:
https://jira.appcelerator.org/browse/ALOY-1118
This because a chicken-egg problem. tiapp.xml is the main config file of your app which is loaded before anything else.
I'd suggest using grunt or gulp to modify the file before you hand it over to Titanium to build.