I added this plugin: https://github.com/aliokan/cordova-plugin-admob
with the command line in PhoneGap 3.3
However I decided to use a different plugin. After attempting an uninstall:
cordova plugin remove com.google.cordova.plugin.AdMobPlugin
I rebuilt the app and launched it on my device. The application compiles fine but the information I display (an RSS feed) does not display the data. Instead, my error catch displays a message. BUT, when I re-install the plugin, it works!
I have not changed any part of the config.xml file, or Android Manifest so I am lost as to why this is happening. Any help?
The plugin adds some authorisations in AndroidManifest.xml when it's added :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I think that your issue is that when you remove the plugin, it doesn't know if this authorisations were already there (added by an other plugin or present by default) or not and removes the lines in all cases.
I suggest you manually edit platforms/android/AndroidManifest to add the lines you need.
If you have no plugins in your project, you will at least need to add android.permission.INTERNET which is present in default cordova project and needed for any app accessing network.
If you have FILE plugin or any other plugin needing to write to sdcard, also add android.permission.WRITE_EXTERNAL_STORAGE.
Related
Yesterday I allowed Android Studio to upgrade the Gradle Plugin to 7.0.1 and since then my project is displaying errors on any code that requires either:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Strangley, code that requires
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
is not showing in error.
The above lines are copied from my AndroidManifest.xml and if I click the suggested fixes in the ALT-ENTER popup to add the permissions it simply duplicates the lines in the manifest and teh error remains.
I have tried resyncing Gradle, Cleaning and rebuilding project and even invalidating caches and restarting, but the errors in the IDE remain.
Building and running the app on AVD devices or a real device works fine.
How can I fix this? Just changing the Gradle Plugin version and Gradle version in Project Structure doesn't seem to help.
Update: I've also tried wrapping the code that shows the errors in an if statement that checks that teh permission has been granted and that makes no difference, so rather than this being a complex Lint check it does seem like a simple misfiring of the API vs Manifest permissions checks...
I try to request permissions to use location data with a flutter app. I am using the geolocator plugin and permission_handler. Both added to my pubspec.yaml.
I have futhermore added
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
to my android/app/src/main/AndroidManifest.xml.
The first thing I do when I launch my app, is
PermissionHandler().requestPermissions([PermissionGroup.location]).then((val) {
...
});
If I then run this on either an emulator or on my physical phone, it returns a PermissionStatus.unknown and subsequent calls to GeoLocator() spams the console with
No permissions found in manifest for: $permission
If I go into app-settings it says that no special permissions were requested.
When I then open up the exact same project as an Android project (I am using Android Studio for both, there is a neat dropdown option to open Android project in Android Studio) and run it on my phone it works as expected - it asks for the permission and if I go into the app-settings I can also see the requested permission there.
Anyone have any idea why it does not get "propagated" with flutter?
It seems like the main issue is that the AndroidManifest.xml is not updated when simply relaunching the application. If, however, one first do a flutter clean and then rebuilds it, the AndroidManifest.xml is updated.
I am not sure if this the intended behavior, but it works. Just something to remember.
Just perform the following command at your command line
flutter clean
after adding permission in AndroidManifest.xml
You just need to perform the two steps:
Add the permissions in the android manifest file.
Execute the command flutter clean in your project.
Take it as a basic rule, after updating the manifest u have to clean the project.
Sorry for the length of this. Please read on.
How can I configure phonegap's project files so that either phonegap platform add or phonegap build generate APK (or intermediate files that are used to generate APK) without any permissions, while not touching any of the /platform/android/ files manually?
Below describes what I tried.
I'm using the latest Phonegap and I'm trying to use CLI (so, not Adobe's build service). I went through everything that I could find online (documentation, forums, here) trying to find at least some hints on how to control the build process, preferably via config (specifically for Android), so that files in /platforms/android/ (e.g. AndroidManifest.xml) get assembled the way that I want.
For example, even with all plugins removed (phonegap plugin remove [plugin name] + manually removed <plugin element from /config.xml, resulting in nothing but an empty json object in /plugins/fetch.json), I can't get AndroidManifest.xml to get created without these 3:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
I'd really not like to get into the discussion of why I'm trying to remove all permissions without manually changing /platform/android/AndroidManifest.xml. I previously used Visual Studio Cordova project template, and I was able to make this work (it's got a different file merge/replacement system, equivalent of which I'm trying to discover on Phonegap side). Both Phonegap and Cordova documentation in general are very selfish/basic, IMO (but, that's another topic).
Of course, I've been removing/re-adding android-platform via phonegap platform remove/add android + phonegap build android each time after config change attempts (which I tried within /config.xml; I also tried to find a spot in the folder tree to place AndroidManifest.xml that would replace the one in /platform/android), but nothing worked. I've been verifying success/failure of my mission via aapt d permissions "platforms\android\build\outputs\apk\android-debug.apk", and by manually checking generated /platforms/android/AndroidManifest.xml, and - no kidding - by release-bulding + signing + uploading to my Google account for their report of my APK (by that was before I discovered aapt.exe).
If anyone can share some links, samples, book titles, or similar - I'd be grateful.
Thank you.
Add:
xmlns:android="http://schemas.android.com/apk/res/android"
to widget declaration in config.xml.
Then add the following:
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
</config-file>
</platform>
Hope it helps!
Hi I'm finding lots of posts about people having to many permissions for their android platform when they use cordova.
I'm missing the INTERNET permission. I can add this manually, but I don't want to do this every single time someone wants to compile an app (The platforms dir is on .gitignore and should not be versioned, so whenever someone takes over the project or w/e it should generate fine).
Currently the manifest adds 2 permissions:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
It should however also add INTERNET, which works fine when I add it manually.
I tried adding
in my config.xml, also
But no cigar, I removed the android platform also to see if it was just not being built.
Recently tried using Phonegap Build, causes the same issue, also for Windows Phone. So currently I can only do iOS properly.
It magically started working, I have no clue why it didn't get added before. I did not even update the platforms or w/e.
I am having an issue in publishing my app in Google play when I include some plugins like cordova-plugin-geolocation in my app, as it adds the following 2 permissions in my manifest file
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
this causes an issue that some of the phones are not able to view the app in the google play as they tell me that android.hardware.location.network access is not compatible on those devices.
when I researched a bit more, I can see that this can be avoided by converting uses-permission to uses-feature and setting the android:required="false" then I can handle it in my code as this is not a must have feature for me.
My issue is I am unable to find how to change this in my visual studio project. can someone please help me understand whats the way to fix this?
Regards
Kiran
There is no way within VS to add contents to your Android projects manifest file. You will have to hand edit those, but beware that these changes would be over-written every time you build your project through VS. There are couple of ways you can workaround this -
You can add post_build Cordova hook that would update the Manifest file.
You can add a gulp task and hook this to MSBuild post_build event through VS.
SOak
(PM - Microsoft)