App installation on Android 6 bypasses the customary 'Permissions' screen - android-6.0-marshmallow

Wanna make an app? - That's simple!
Wanna make it work on different versions? - Learn rocket science.
Have seen the following answers and more, but none helped:
Answer 1
Answer 2
Answer 3
So, here's my AndroidManifest chunk:
:
:
:
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<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.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
:
:
and the relevant chunk from build.gradle:
:
:
android{
compileSdkVersion 23
buildToolsVersion "23.0.2"
:
:
When I first installed the app on Marshmallow (6.0.1), the installer said (something very similar to) - "it requires no special access (or permissions)". The app failed to go beyond the splash screen too, whereas on other Android versions, the sailing is smooth and complete.
The answers listed above explain why, (change in the permission model etc.), from which I cannot figure out what really to do.
My requests are:
Please let me know how to make the app install exactly as it installs on lesser versions than 6.0.
How to keep code changes (if required) to the barest minimum
How not to complicate the existing, automatic permissions request at install time (with run-time permissions and all that).
Many thanks in advance!

Welcome to Marshmallow. Android M(6.0) introduced runtime permission model. You are suppose to handle requesting for permissions in runtime. You could refer to my github sample on how to do it. There are a few other libraries like easypermissions to enable developer get rid of the hassles.

Related

Do WinUI applications need runFullTrust to publish to the Windows Store?

I recently took a stock WinUI template, added my old UWP C# code, recompiled and tried to publish. The Windows Store Application Submission warns me that I shouldn't use the runFullTrust setting:
We detected the use of one or more restricted capabilities in your Package.appxmanifest file. You must request approval to use restricted capabilities by providing more information below. Please include as much detail as possible. Learn more
If you don't need to declare these capabilities or added them in error, you can remove them from your Package.appxmanifest file and then upload the updated package(s).
but here's what I got from the template:
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
I tried removing it, but it wouldn't even compile. Can anyone tell us the backstory of this flag, why it's needed in WinUI but not UWP, and how we get around the Windows Store Submission error.
Do WinUI applications need runFullTrust to publish to the Windows Store?
Yes.
A WinUI 3 app uses the full-trust desktop app model. A UWP app runs in a sandbox.
As stated in the docs, distributing your packaged desktop (WinUI 3) app requires you to answer "a few extra questions as part of the submission process. That's because your package manifest declares a restricted capability named runFullTrust, and we need to approve your application's use of that capability."
So you should provide information about why you need to use the runFullTrust restricted capability when you publish the app. You could for example explain that it's a desktop app and what it does.
WinUI 3 does not need to be full trust, but you still need to declare any UWP-like capacities you are using.
Here is a tutorial that shows how to do it.
https://nicksnettravels.builttoroam.com/winui-appcontainer/

How to use the Storage Attach Service for public storage access instead of private storage access?

Problem Summary
My app (in development), when run on the desktop, can both:
Write to & read from private storage
Write to & read from public storage.
However, when run on Android, only private storage is accessible.
How To Replicate The Issue
Instead of sharing excerpts of my project's codebase, let me refer to another codebase we share and have - the gluon-connect-file-provider project in Gluon Samples. The sample apps only demonstrate private storage usage. None demonstrate public storage usage, so in the gluon-connect-file-provider project, you can make the following change in com.gluonhq.samples.connect.file.Main.java:
Before
static {
ROOT_DIR = Services.get(StorageService.class)
.flatMap(StorageService:getPrivateStorage)
.orElseThrow(() -> new RuntimeException("Error retrieving private storage"));
}
After
static {
ROOT_DIR = Services.get(StorageService.class)
.flatMap(s -> s.getPublicStorage("Gluon"))
.orElseThrow(() -> new RuntimeException("Error retrieving public storage"));
ROOT_DIR.mkdir();
}
When starting the app on the Desktop after this change, you can first observe the directory ~/Gluon being created on your machine. Then, as you toggle the checkbox on/off in the app's Object Viewer screen, you can also confirm the underlying JSON file ~/Gluon/user.json is being updated. So, therefore, we can agree public storage works.
However, when deployed to Android, we can see file-permission related failures in the scrolling terminal during mvn -Pandroid gluonfx:nativerun. First, the Gluon directory fails to be created at startup and, consequently later, attempts to write the user.json file occur.
I thought the soluton was to define in the project the file src/android/AndroidManifest.xml. The default found at target/gluonfx/aarch64-android/gensrc/android/AndroidManifest.xml does not include the following permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
So, I copied the generated AndroidManifest.xml file to src/android, including these entries to it. Even though the Android Settings shows me my app has Storage Permission, this still didn't resolve the problem.
Note - when preparing this post asking for your help, I noticed that, without also provisioning src/android/AndroidManifest.xml file with EXTERNAL READ/WRITE permissions for the gluon-connect-file-provider, the Android device already showed the deployed app had Storage Permission enabled.
I used two different Android devices to test with.
Pixel XL running Android version 10.
Samsung S9 running Android version 10.
I tested with the latest GluonHQ Attach dependency 4.0.13 and also with the oldest I found available, 4.0.7.
Is there something more that must be done for the Storage Attach Service to allow public storage access on Android? Please tell me how else to modify the gluon-connect-file-provider app to make it so, thank you.
Resolution
Update to Gluon Attach 4.0.14.
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>4.0.14</version>
</dependency>
With this update, Storage Service will allow you to access pre-existing Android folders, like "Documents" for example. Or, as seen in this post's code excerpt above, you can define your own new directory like "Gluon", or naming the folder after your own App.
Extra
Another cascading result of this Attach update is, in addition to Storage Service, file sharing via the Share Service is now available on Android. Its JavaDoc states Storage Service as a requirement to use Share Service. Below is a quote from its documentation:
Note that on Android, the file has to be located in a public folder
(see StorageService#getPublicStorage), or sharing it won't be allowed.

Two Cordova plugins using Firebase.Core framework causing conflicts when building application

I need to use two cordova plugins within my Ionic application:
Firebase: https://github.com/arnesson/cordova-plugin-firebase
Firebase Dynamic Links: https://github.com/chemerisuk/cordova-plugin-firebase-dynamiclinks
When attempting to build my application, I run in to an error that I believe has to do with Firebase.Core being requested in two locations and (possibly) using different versions(?). On build, I get the following error (there's a ton of these so here's one, let me know if you need all):
duplicate symbol _FIRAuthStateDidChangeInternalNotificationTokenKey in:
/Users/jordan/Downloads/ReleaseHub/platforms/ios/build/emulator/libFirebaseCore.a(FIRApp.o)
ReleaseHub/Plugins/cordova-plugin-firebase/FirebaseCore.framework/FirebaseCore(FIRApp.o)
When looking at the plugin.xml for each, I see that Firebase has:
<framework custom="true" src="src/ios/Firebase/Analytics/FirebaseCore.framework" />
While Dynamic Links has:
<framework src="Firebase/Core" type="podspec" spec="~> 5.0"/>
Thus I am led to believe that this is where the conflict sits, due to the "duplicate" variable. Am I on the right track? How do I get these two plugins to play nicely with each other? Thanks!
And just to clarify, when I remove the dynamic links package from my project, the project builds as expected.
I managed to solved it by replacing cordova-plugin-firebase with this forked plugin https://github.com/dpa99c/cordova-plugin-firebase.
Maybe you can give it a try.

Android 6 android.permission.READ_PHONE_STATE allow on install

I'm using Android 6 with target SDK 23.
I need to accept one permission(READ_PHONE_STATE) on install, like it was before target SDK 23, in google store it shows you permission and you accept it, then app will be installed.
I don't want to use a popup. I need to you use target SDK 23 but without popup of permissions. You will say - it's impossible! But, maybe anybody knows how?
P.S. Normally it should be some flag in AndroidManifest or gradle...
P.S.S : Should be like that below
And not like that below :
if you want that no pop up will be shown or directly setup permissions then you have to do like this:
http://www.howtogeek.com/230683/how-to-manage-app-permissions-on-android-6.0/

Google maps v2 grey screen on AVD with 4.3 SDK 18

I created my google api key for google maps v2 for android, everything is set up in eclipse for google maps (using google+api build, linking to google play services, api key sorted, etc), I can view a map app fine on my phone but when I view the same app on the AVD it's going to the right location and I can see all the google map overlays (such as zoom button) but there is no map, it is just a grey box. Networking is fine as well.
I am using the latest 4.3 API 18 build and my AVD is the default Nexus One. Prior to this I got the dreaded 'update google play services' message which I found was due to maps v2 simply not working on 4.2 so I upgraded reading that maps should work ok with SDK 18 on AVD.
Any idea why it's not showing? I did notice when I start the AVD it says using software opengl but I'd have thought it was ok.
I've read various stackoverflow articles but they all point at an incorrect configuration and mine is fine and working just dandy when I send it to my phone and it's throwing no errors.
If it's any help here are some snippets of code I'm using.
manifest:
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-library android:name="com.google.android.maps" />
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="XXXXXXXXXXXXXXXXXXXX"/>
layout snippet:
<fragment
android:id="#+id/worldmap"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
code to initialise a map:
private void initialiseMap() {
if (googleMap == null) {
googleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(
R.id.worldmap)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(activity.getApplicationContext(),
"Unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
code to display the map:
private void displayLocation(Location l, String text) {
if(googleMap!=null) {
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
LatLng ll=new LatLng(l.getLatitude(), l.getLongitude());
CameraPosition cp=new CameraPosition.Builder()
.target(ll)
.zoom(18)
.build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cp));
Toast.makeText(activity, l.getLatitude()+":"+l.getLongitude(), Toast.LENGTH_LONG).show();
}
}
You should see something like
E/Google Maps Android APIļ¹• Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
in the console. This is a known problem with emulator with Google APIs. I suggest switching to Genymotion, which works and works very well.
To run Google maps successfully on AVD
Create a non Google API emulator API level is higher than 3.0
Download Google play services apk using online apk downloader in to your pc (must be the latest version)
Download Google play srore apk (must be the latest version)
Install those apks using adb install command on
Android emulator
Now everything is ready to test Google maps v2 on the emulator. Run your application on the emulator
In my experience I've seen that just getting a grey map means that there is some license key problem (so Google is refusing to server up the colorful map tiles), but otherwise everything else is probably fine with your app (especially if you can scroll around the grey map).

Resources