Insecure HTTP is not allowed by platform - flutter

I am facing following issue :
I/flutter (31349): Bad state: Insecure HTTP is not allowed by platform: http://max-image-caption-generator-test.2886795296-80-host19nc.environments.katacoda.com/model/predict
I added following lines in android/app/src/main/AndroidManifest.xml file
<uses-permission android:name="android.permission.INTERNET" />
<application
android:usesCleartextTraffic="true"
</application>
But still I am facing the error

HTTP connections are not allowed anymore since Flutter 2.0 on Android and iOS.
There are two solutions: You can use only HTTPS connections or you can activate unsecure connections (e.g. for debugging). The following article describes how to do this: https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android or Flutter Insecure http is not allowed by platform

You need to take permission to use http
For Android -> android:usesCleartextTraffic="true" in application in AndroidManifest.xml file
<application
...
android:usesCleartextTraffic="true">
For IOS -> add below lines in Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Related

I am having issues uploading my app to Google playstore

I have been trying to upload my flutter app to playstore, but it got rejected, I got an email like this below
This is how my pubspec.yaml file look like
my Androidmanifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test" xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I was thinking maybe the permission_handler is the cause of the rejection,
but based on my research online, I believe it suppose to go through since I added this
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove"/>
I think you misunderstood the Google Playstore message.
They are telling you that your app shouldn't use this permission:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove"/>
So you have two options:
Either Remove this permission request from your app or
argue with the Google Playstore support about why your app really needs this permission. They list a few allowed cases (web browsing as a core functionality for example)

Why with wifi I can connect but not with my mobile data

Hello I have a problem this morning that I did not meet. with wifi I can connect with the application but not with my mobile data. Can anyone help me? Here is the content of
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:label="FACTURA"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
Starting with Android API 28 and iOS 9, these platforms disable insecure HTTP connections by default.
You can use this code:
Add network-policy at your meta-data in AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
....
<meta-data android:name="io.flutter.network-policy"
android:resource="#xml/network_security_config"/>
Allowing cleartext connection for debug builds:
Look at: $project_path\android\app\src\debug\AndroidManifest.xml:
<application android:usesCleartextTraffic="true"/>
You can see this documentation:
https://docs.flutter.dev/release/breaking-changes/network-policy-ios-android

Flutter Cleartext HTTP traffic not permitted

I have gone through the usual answers. I have edited the info.plist on iOS and added the network_config.xml in Android. This works perfectly when running the project from XCode, but when trying to run the debug from Android Studio, I get the
Cleartext HTTP traffic to 192.168.1.54 not permitted
Seems like Flutter is ignoring my iOS and Android configurations regarding this matter, but only when running it directly from Android Studio.
Please add below code in your manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
You can read details here https://medium.com/#imstudio/android-8-cleartext-http-traffic-not-permitted-73c1c9e3b803

WKWebview runs fine in iOS 10, freezes in iOS 9

I installed the WKWebview plugin from driftyco Github page and my app runs normally in ios 10. However, when I installed the app on iOS 9, the app freezes at the splash screen.
I read about the ATS and in my info.plist, I have this value
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Here is my access-origin and allow-navigation tag
<access origin="*" />
<allow-navigation href="*" />
What else do I need to do to make WKWebview work? I have WKWebview v1.1.1 and Cordova iOS 4.1.1.
I also noticed an error "DOM Exception 18: An attempt was made to break through the security policy of the user agent."
Another interesting error is
[Error] module cordova-plugin-nativestorage.NativeStorageError already defined
define (cordova.js:79)
Global Code (NativeStorageError.js:1)
[Error] Failed to load resource: unsupported URL (ready, line 0)
Please help!

how to generate keystore for android with google maps in titanium?

I'm trying to generate a valid keystore for my application with the signature algorithm: SH1withRSA.
I have generated an API key with SHA1 from the keystore that was generated previously and set tiapp.xml to use Google maps v2:
<manifest android:versionCode="10" android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="com.vivelabbogota.idutest.permission.MAPS_RECEIVE"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission
android:name="com.vivelabbogota.idutest.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application android:debuggable="false">
<meta-data
android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBtJKvPPfpbioLqKVz213JOYDxOpoHCriE"/>
<uses-library android:required="true" android:name="com.google.android.maps"/>
</application>
<application android:theme="#style/Theme.NoActionBar"/>
<!-- Need to specify at least API level 11 for Titanium SDK 3.2.x and prior -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16"/>
</manifest>
Later, I built a signed apk with the keystore, but when I install this apk the map does't load (only shows a grid). In the other hand if I sign the apk with default Titanium keystore, which is signed with MD5withRSA, the map loads.
Can you help me with this?
Your problem i think is that you use the same api key for two different type of service , your map loads on debug but not on release ! you have to know that you have to generate another SHA1 with your keystore not debug.keystore , and then generate a new api key in google console with your keystore SHA1 .
hope it can help
In Google Developers you added SHA1 for developer key only. That's why it stopped working when you signed it with distribution key. Just add SHA1 for distribution key for API key you generated (yes, you can add multiple SHA1 for same API key). This way you won't have to change anything in app and it will allow you to switch between developer/distribution version with maps working any time you want.