Android "Not granting permission" error - android

I've been recently exploring the device administration APIs, and i've found that neither my code, nor the sample code on the android developing website have been able to enable the device administration.
The error i get on launching is:
12-28 17:24:49.596: WARN/PackageManager(60): Not granting permission android.permission.BIND_DEVICE_ADMIN to package com.example (protectionLevel=2 flags=0x8446)
and then this when i try to enable the administrator:
12-28 17:27:22.426: WARN/DeviceAdminAdd(396): Unable to retrieve device policy ComponentInfo{com.example/com.example.Receiver}
org.xmlpull.v1.XmlPullParserException: No android.app.device_admin meta-data
I set all the permissions exactly the same as per the requirements for the manifest:
<activity android:name=".MyActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".Receiver"
android:label="device_admin"
android:permission="android.permission.BIND_DEVICE_ADMIN"/>
<meta-data android:name="android.app.device_admin"
android:resource="#xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
</intent-filter>
and the device policies are also set exactly as per the requirements stated by the APIs.
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<limit-password />
<watch-login />
<reset-password />
<force-lock />
<wipe-data />
</uses-policies>
Did i make a mistake in getting the permission or is device administration not available without extra code signing?

You have badly formatted XML as you have closed your <receiver /> tag before the specifying the meta-data element. Here's what it should be:
<receiver android:name=".Receiver"
android:label="device_admin"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.device_admin"
android:resource="#xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
</intent-filter>
</receiver>
Other thoughts that came to mind:
In my project the device_admin.xml file is in the \res\xml directory. Maybe make sure your XML file is there?
Do you need #string on the android:label for the receiver? e.g.
android:label="#string/device_admin"
I'm not sure about this, but do you also need to add a uses-permission XML element to your Manifest.xml too?

according to the http://developer.android.com/guide/publishing/app-signing.html
the debugger signs it just for compiling + running purposes. Wouldn't it still be able to run in the debugger?

Related

Google play not accepting instant app due to digital asset link

I've been trying for a week to solve this issue with no luck!
Google play is still not convinced that I have linked my website properly!, whenever I upload my instant app I get the usual:
Your site 'www.servstore.co' has not been linked through the Digital Asset Links protocol to your app. Please link your site through the Digital Asset Links protocol to your app.
Noting that both my instant app and installed app have the same code base (single module), and are actually 9.4 MB after minification.
I know this has been asked multiple times, and I've seen mutiple SO posts about this, however none of the resolutions I've read seem to work for me, I actually tried all of them so far with no luck, What I've done so far to debug this issue:
Website Side:
Made sure assetlinks.json is uploaded to my website and administered with appropriate Content-Type header.
Made sure the file is available with public permission (777)
Made sure robots.txt allows crawling for the file, I actually only have the below in it:
User-Agent: *
Allow: /.well-known*
Verified asset link https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://www.servstore.co&relation=delegate_permission/common.handle_all_urls
made sure the asset link is using the right SHA-256 (private key in Google Play), I also never use an upload key, I directly sign my app with the same key and have opted in to Google play signing using that key.
App Side:
added asset_statements to my strings.xml and meta-data under application tag in AndroidManifest.xml
Made sure the first intent-filter containing app link has auto-verify = true in my manifest, also tried to mark all 3 activities that have intent-filter URLs with auto-verify
Added default-url in the manifest to all 3 activities and tried with only the main activity.
Added networkSecurityConfig to xml resources and reference it in the manfiest:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">www.servstore.co</domain>
</domain-config>
</network-security-config>
In Google Play:
Enabled instant-app release type in new Google Play console.
published the same code to standard release type in Google Play with version code higher than the one I use for my instant app.
I am ready to try anything ..
here is my manfiest file, removing unrelated activities:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="co.servstore.client"
android:targetSandboxVersion="2">
<dist:module dist:instant="true" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:name=".ServStoreApp"
android:allowBackup="false"
android:icon="${appIcon}"
android:label="#string/app_name"
android:roundIcon="${appIconRound}"
android:supportsRtl="true"
android:theme="#style/Theme.ServeStore.NoActionBar"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:allowBackup,android:theme"
android:networkSecurityConfig="#xml/network_security_config">
<service
android:name=".services.notifications.NotificationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="***" />
<meta-data
android:name="asset_statements"
android:resource="#string/asset_statements" />
<activity
android:name=".ui.main.MainActivity"
android:screenOrientation="nosensor"
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.servstore.co"
android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://www.servstore.co" />
</activity>
<activity
android:name=".ui.orders.OrderDetailsActivity"
android:screenOrientation="nosensor">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.servstore.co"
android:path="/businessOrders"
android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://www.servstore.co" />
</activity>
<activity
android:name=".ui.orders.CustOrderDetailsActivity"
android:screenOrientation="nosensor">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.servstore.co"
android:path="/userOrders"
android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://www.servstore.co" />
</activity>
</application>
</manifest>
To resolve to a particular host url, you should provide the host.
Can you try to remove:
<data android:scheme="http" />
Or add host for the http scheme like below
<data
android:host="www.servstore.co"
android:scheme="http" />
I have had similar difficulties and am trying some things that might help you. Your problem might be a missing intermediary SSL certificate.
When you run the App Link Tester you probably are getting an error response "URL resolving conflicts, please link and verify your digital asset links"
If you then run Postman to connect to your domain (by https) you get an "SSL error: Unable to verify the first certificate". But you will find an HTTPS browser connection to a page on your server works fine.
In my case I understand from Sectigo that one intermediary certificate is installed with the SSL, but the second one is not. I would suggest that you call Sectigo tech support (888.391.4357). You may need guidance to get the missing intermediary certificate.
You didn't include your build.gradle(app) so you might check your SDK versions. They may be tied up with the problems with the READ_PHONE_STATUS permission which you do require as reported in Google play not accepting instant app due to digital asset link
If you have simply accepted the addition implicitly, you might try removing it:
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
tools:node="remove" />
That post also indicates problems with certain versions of play-services. Try:
implementation 'com.google.android.gms:play-services-base:17.6.0'
implementation 'com.google.android.gms:play-services-instantapps:17.0.0'

Google Analytics not communicating to server - AnalyticsReceiver is not registered or is disabled - error

I have setup react native firebase on my android react-native app to track app hits on analytics. But the hits are not reaching from android emulator. So, I checked the log with adb logcat and found out the below warnings and suspect that this might be causing the issue.
AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See link for instructions.
CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See link for instructions.
AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See link for instructions.
I followed this post and did some changes to the manifest file.
Modified AndroidManifest.xml file:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.truuue.truuuerental">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="false"
android:theme="#style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="truuuetenant" android:host="*" />
</intent-filter>
</activity>
<receiver android:name="com.appsflyer.SingleInstallBroadcastReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background dispatching on non-Google Play devices -->
<receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
<!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
installation campaign reporting -->
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyB3stzerjTZEubg4WqkF1mJeqAB7TcnXj0"/>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>
But still the error is appearing. Any idea on how to solve this issue?
According to the mail that I recently received from Google Analytics team,
What does “stopped processing” mean?
New data you send to the Google Analytics properties listed above will
not be serviced and will therefore, not appear on your reports. This
will appear as though you are no longer sending app data to Google
Analytics.
What will happen to my Google Analytics properties listed above?
Reporting access through our UI and API access will remain available for these properties’ historical data until January 31,
2020.
After our service is fully turned down in February 2020, these legacy properties will no longer be accessible via our Google
Analytics UI or API, and the associated data will be deleted from
Google Analytics servers. In advance of this turndown, we recommend
that you retrieve this historical data through report exports.
NOTE: Bottomline, it is advised to follow and use the Firebase Analytics for reports.

Android settings crash when trying to set default app (Host-based card emulation)

I'm trying to implement a Tap & Pay application and therefor need to communicate with a POS Terminal. In order to do so, the device needs to set my application as the default application for Tap & Pay functionalities. Whether trying to ask the user to set it programmatically or via settings app, android Settings crashes.
I figured it has something to do with the manifest file since the crash apparently occurs during the process of listing the tap & pay apps.
I've followed the instructions on host based card emulation I've found on the android developer page https://developer.android.com/guide/topics/connectivity/nfc/hce
manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="wizypay.brantner.wizy">
<uses-feature android:name="android.hardware.nfc.hce" android:required="true"/>
<uses-permission android:name="android.permission.NFC" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_wizy"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_wizy"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".acitvities.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".acitvities.MainActivity" />
<activity android:name=".acitvities.RegisterActivity"/>
<service android:name=".services.HostCardEmulatorService" android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="#xml/apduservice"/>
</service>
</application>
</manifest>
apduservice.xml:
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="#string/servicedesc"
android:requireDeviceUnlock="false"
android:apduServiceBanner="#drawable/my_banner">
<aid-group android:description="#string/aiddescription"
android:category="payment">
<aid-filter android:name="A0000000043060"/>
<aid-filter android:name="315041592E5359532E4444463031"/>
<aid-filter android:name="325041592E5359532E4444463031"/>
<aid-filter android:name="44464D46412E44466172653234313031"/>
<aid-filter android:name="A00000000101"/>
<aid-filter android:name="A000000003000000"/>
<aid-filter android:name="A00000000300037561"/>
<aid-filter android:name="A00000000305076010"/>
...
</aid-group>
</host-apdu-service>
I'm currently testing the application on a Google Pixel running Android 8.1.0
I hope someone has an idea what could cause the crash,
thanks in advance!
There doesn't seem to be anything wrong with your code.
I've found a list of Application Identifiers though https://www.eftlab.co.uk/index.php/site-map/knowledge-base/211-emv-aid-rid-pix
After playing around a bit I've found out that android set a limit to the possible amount of AIDs that can be registered, which seems to be at 260. Maybe you added too many?

Can't find uses-permission into manifest file

I'm trying to upload a new version of an application into Google Developer Console.
At the end of the upload, the console show this error message:
"Your APK uses permissions that require the setting of privacy policies: (android.permission.CAMERA)"
So I think that I have this uses-permission into the manifest file and I need to add a google privacy policy.
That's ok, but this is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="simone.biliato.delonghitrevisotvb">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="simone.biliato.delonghitrevisotvb.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="simone.biliato.delonghitrevisotvb.NotificationInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name="simone.biliato.delonghitrevisotvb.NotificationMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
Where are all the permissions? Why I don't see them? I'm sure that I added them earlier and now disappear. Is there a specific location? A list of all permission for the project?
User permissions are made up from the ones you have in your manifest and those that come from the library or dependencies you have in your project. The result will be a manifest merged by all of them. Check your dependencies.
You can use the apk analyzer : https://developer.android.com/studio/build/apk-analyzer.html
Our friends from CommonsWare give us a good solution to detect where the permissions come from:
https://commonsware.com/blog/2015/06/25/hey-where-did-these-permissions-come-from.html
To get a better sense of where those elements are
coming from, we can look at
app/build/outputs/logs/manifest-merger-debug-report.txt.

Android Play Store Campaign tracking pre-requisites

I'm attempting to use a campaign to promote my application. I've found these instructions and am attempting to do step one:
https://developers.google.com/analytics/devguides/collection/android/v2/campaigns#google-play-campaigns
However, my IDE (IntelliJ) is telling me it cannot resolve "com.google.analytics.tracking.android.CampaignTrackingService" in the Manifest file.
Is this a Bug in the IDE? Or is there a library I'm meant to be including with my application? And are there any other steps they have missed out? E.g. do I need to be adding internet permissions to my application?
When I run the application it seems to work fine, and here is my Android Manifest file:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" />
<application
android:icon="#drawable/ic_launcher_toddlerswords"
android:label="#string/app_name"
android:hardwareAccelerated="true">
<activity android:name="maddy.toddlercolors.ToddlerWords"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="maddy.toddlercolors.menu.QuickPrefsActivity" android:label="#string/app_name"/>
<!-- Used for install referral measurement-->
<service android:name="com.google.analytics.tracking.android.CampaignTrackingService"/>
<receiver android:name="com.google.analytics.tracking.android.CampaignTrackingReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>
After some further reading it looks like campaign tracking requires a google analytics jar, and will require internet permissions.
https://developers.google.com/analytics/devguides/collection/android/v2/

Categories

Resources