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" />
Related
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.
I am new to programming generally please I need some help!
My app was installing successfully after every update until i decided to add the 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha' library to the app because i need the user to be able to view some data in form of statistical charts.
The library was synced successfully and have used packages and classes therein successful. But when i try to install the app in my android device it returned this error:
Installation failed with message Failed to commit install session 590492354 with command cmd package
install-commit 590492354. Error: INSTALL_FAILED_MISSING_SHARED_LIBRARY: Package couldn't be installed in
/data/app/com.cenitscitech.www.etimebook-jOP-jv2YuNu7_8qnkfqp-A==: Package com.cenitscitech.www.etimebook requires unavailable shared library com.google.android.things; failing!.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing." I have pasted a screenshot here:
I uninstalled the existing version of the apk, cleared some memory space but keep on getting the same message! What should I do next please?
You are most likely installing on a device that is not an Android Things device. I suspect the library you added either has some transitive dependency on com.google.android.things, or something else changed in your project.
To get around this, you must do the following 2 things:
1. Mark that Android Things is not required on the device in your AndroidManifest.xml file:
<uses-library
android:name="com.google.android.things"
android:required="false"
tools:replace="android:required" />
(tools:replace is not strictly required, but it just there in case something in the manifest merge process overrides your setting.)
2. In your app's code, before making any calls to the Things APIs, make sure that they are available on the current device. This can be tested with the following code snippet:
public boolean isThingsDevice(Context context) {
final PackageManager pm = context.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
}
Only doing 1 should fix the install problem, but your app will crash if you make any Things API calls on a device that isn't an Android Things device.
Had a look in the com.github.PhilJay:MPAndroidChart:v3.1.0-alpha repository and did not find any reference to com.google.android.things inside the source code.
You need to remove the below entry in case it's found in the AndroidManifest.xml of your app for it to work on your device again:
<uses-library android:name="com.google.android.things" />
My App was removed by google because of presence of SMS and Call Permission in manifest. Now I have removed both the permission then also I'm not able to upload the apk .play store asking for the Permissions Declaration Form
Most likely some library you're using is adding the permissions. You can remove them during merge by adding the following to your AndroidManifest.xml:
<uses-permission android:name=”android.permission.RECEIVE_SMS” tools:node=”remove” />
<uses-permission android:name=”android.permission.SEND_SMS” tools:node=”remove” />
<uses-permission android:name=”android.permission.WRITE_SMS” tools:node=”remove” />
<uses-permission android:name=”android.permission.READ_SMS” tools:node=”remove” />
See this SO question for additional information.
You have to release a build with those permissions and fill the form (form will appear automatically on release page), then after that, you have to upload a build without those permissions.
I got the same problem recently and i have to removed those permissions and later my app got published. Please type all your permission you using in your app?
Remove SMS and CALL-Log permission from manifest file and Build new APK upload in Internal Test Track and deactivate previously released APK in internal Test track and roll out, Then release same APK in Alpha and Beta, Then Previously Declared Permissions will be automatically removed and release app to production and roll out
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.
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.