Xamarin: Issue when TargetSdkVersion set to API 31 in manifest - xamarin.android

By refer to Xamarin.Android 12.0 Release Notes, I set TargetFramework to Android 12 and I able to deploy project without any problem.
However, I encountered following error when I set android:targetSdkVersion to API 31 in android manifest.
ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl204773411.tmp/base.apk (at Binary XML file line #84): com.urbanairship.accengage.PackageUpdatedReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
This happens only when android:targetSdkVersion set to 31 and deployed to physical device/emulator with android 12. I already added android:exported="true" to MainActivity class and classes that use intent filters. Could anyone advice me how to resolve this?
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.myapp.simulation" android:versionName="1.0.30" android:versionCode="110" xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application tools:replace="android:allowBackup" android:name="android.support.multidex.MultiDexApplication" android:icon="#drawable/launcher_icon" android:allowBackup="false" android:fullBackupOnly="false" android:label="Sample App">
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:enabled="true" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
</application>
</manifest>

According to the error message, the PackageUpdatedReceiver in your project doesn't set a value for the android:exported. So you can try to set a value by the two following ways.
Set it in the attribute of the BroadCastReceiver:
[BroadcastReceiver(Exported = true)]
Set it into the application label in the AndroidManifest.xml:
Edit: For android 12, all the Services, BroadCastReceivers, Activity classes need to declare the value for the android:exported. So update the three part sdk to the last version.

Related

Getting blank screen in IPA after updating angular cordova-ios platform

Initially we were using angular cordova-ios version as 4.5.4 and while uploading the IPA to Apple Store Connect it gave UIWebView error hence, upgraded the cordova-ios platform to 5.1.1 and added cordova-plugin-wkwebview-engine plugin. Now on generating IPA , it shows blank screen and doesn't route to the login screen.
Version details are as below:
angular-devkit/architect 0.10.7
#angular-devkit/build-angular 0.10.7
#angular-devkit/build-optimizer 0.10.7
#angular-devkit/build-webpack 0.10.7
#angular-devkit/core 7.0.7
#angular-devkit/schematics 0.8.9
#angular/cli 6.2.9
#ngtools/webpack 7.0.7
#schematics/angular 0.8.9
#schematics/update 0.8.9
rxjs 5.5.12
typescript 2.9.2
webpack 4.19.1
cordova-ios 5.1.1
We used the below command to build:
ng build --prod --source-map=false && cordova build ios
Our config.xml file
<?xml version='1.0' encoding='utf-8'?>
<widget android-activityName="appname" android-versionCode="10002" id="appname" version="1.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>appname</name>
<description>
Description
</description>
<author email="Support#appname.com" href="http://appname.com">
appname
</author>
<content src="index.html" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<icon density="ldpi" src="res/icon/android/ldpi.png" />
<preference name="CustomURLSchemePluginClearsAndroidIntent" value="true" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<icon density="ldpi" src="res/icon/android/ldpi.png" />
</platform>
<hook src="hooks/appBeforeBuild.js" type="before_build" />
<hook src="hooks/appBeforeBuild.js" type="before_run" />
<engine name="browser" spec="^5.0.3" />
<plugin name="cordova-plugin-dbcopy" spec="^2.1.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-network-information" spec="^2.0.1" />
<plugin name="uk.co.workingedge.cordova.plugin.sqliteporter" spec="^1.1.0" />
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-printer" spec="^0.7.3" />
<plugin name="cordova-plugin-file-transfer" spec="^1.7.1" />
<plugin name="cordova-plugin-customurlscheme" spec="^4.4.0">
<variable name="URL_SCHEME" value="URL_SCHEME_NAME" />
<variable name="ANDROID_SCHEME" value=" " />
<variable name="ANDROID_HOST" value=" " />
<variable name="ANDROID_PATHPREFIX" value="/" />
</plugin>
<plugin name="cordova-plugin-dialogs" spec="^1.3.3" />
<plugin name="cordova-plugin-bluetoothle" spec="^4.5.10" />
<plugin name="cordova-plugin-bluetooth-peripheral-usage-description" spec="^1.0.1">
<variable name="TEXT" value="Some string" />
</plugin>
<plugin name="cordova-plugin-geolocation" spec="^4.0.2" />
<plugin name="cordova-plugin-android-permissions" spec="^1.0.2" />
<plugin name="cordova-plugin-ble-central" spec="^1.2.5" />
<plugin name="cordova-plugin-inappbrowser" spec="^3.2.0" />
<plugin name="cordova-plugin-permission" spec="^0.1.0" />
<plugin name="cordova-plugin-vibration" spec="^3.1.1" />
</widget>
Unfortunately, white screen errors are pretty generic, as the error condition isn't listed in the console (see Cordova - white screen after splash, no exceptions in console).
You can, however, launch the app in the iOS simulator and hook it up to Safari's dev tools, and then hit refresh. It should kick out the exception that iOS is running into.

Error: Invalid resource directory name for splash

I have a Nuxt JS / Cordova 8.0.0 project with a few plugins. I'm trying to add custom splash screens to the project, and have added them inside of res/screen/android/
Every time I try to compile the project, I get the following error when building for Android:
`Execution failed for task ':app:mergeDebugResources'.
/Applications/MAMP/htdocs/project-beacon/cordova/platforms/android/app/src/main/res/drawable-xhdpi-portrait: Error: Invalid resource directory name`
This is really frustrating.
I have my config.xml file setup as follows:
<platform name="android">
<preference name="SplashMaintainAspectRatio" value="true" />
<icon density="ldpi" height="36" src="res/icon/android/icon-36-ldpi.png" width="36" />
<icon density="mdpi" height="48" src="res/icon/android/icon-48-mdpi.png" width="48" />
<icon density="hdpi" height="72" src="res/icon/android/icon-72-hdpi.png" width="72" />
<icon density="xhdpi" height="96" src="res/icon/android/icon-96-xhdpi.png" width="96" />
<splash density="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
<splash src="res/splash/android/Default#2x~universal~anyany.png" />
<allow-intent href="market:*" />
<custom-config-file parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
</custom-config-file>
</platform>
Originally, I had a load of splash screens, but due to the error, I've removed them to see if it would fix it. I have tried changing the file names and everything.
You have 2 <platform name="android">
Also you have <splash src="res/splash/android/Default#2x~universal~anyany.png" /> which has no density, remove it.

Android Migration To Android studio 3.0 Manifest Errors

After Automatic actualization To Android 3.0 I keep Getting Manifest Error Althought Nothing was Changed by me In It.
I had Tried to
1) Reinstall Android Studio couple time
2) Clean Cache
3) Download SDK One more Time
4)I was Searching For inconsistience in build gradle.
Nothink Helped, One of Many problems in Manifest is That
Te fatal Problem is Error:(82) error: unknown element found.
MY MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lenovo.licz4"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.AUTHENTICATE_ACCOUNTS"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission
android:name="android.permission.USE_CREDENTIALS"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<meta-data
android:name="android.support.VERSION"
android:value="26.0.0-alpha1" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.lenovo.licz4.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.lenovo.licz4.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" >
<service
android:name="com.example.lenovo.licz4.SyncService"
android:exported="true"
android:process=":com.example.lenovo.licz4.sync" >
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="#xml/syncadapter" />
</service>
<service android:name="com.example.lenovo.licz4.AuthenticatorService" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator" />
</service>
<provider
android:name="com.example.lenovo.licz4.StubProvider"
android:authorities="com.example.lenovo.licz4"
android:exported="false"
android:syncable="true" />
<activity android:name="com.example.lenovo.licz4.Activities.CopyDbActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<account-authenticator
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="http://example.com/"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:smallIcon="#drawable/ic_launcher" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" >
</receiver>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:permission="android.permission.INSTALL_PACKAGES" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.lenovo.licz4" />
</intent-filter>
</receiver>
<!--
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.example.lenovo.licz4.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
MY BUILD GRADLE
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.lenovo.licz4"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.firebaseui:firebase-ui-storage:0.6.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I too had this problem and almost tried what you have tried.
My problem was solved by adding
android.enableAapt2=false
on grable.properties of project.
I hope this will help you too.

Ionic View with Ionic 2 app

I know the Ionic View does not support all Cordova plugins (http://docs.ionic.io/docs/view-usage).
I have an app that is working in Chrome and on Android device.
When trying the same app with Ionic View with my Android device, it seems the http requests are not returning anything.
I don't see whitlist support, so do you think it could be the cause of my issue?
If so, is there a way to make it work?
Any plan, by Ionic team, to add that cordova plugin support?
[UPDATE]
Here is my AndroidManifesst.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:label="#string/share_name" android:name="com.google.zxing.client.android.encode.EncodeActivity">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.ENCODE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:label="#string/share_name" android:name="com.google.zxing.client.android.HelpActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
</manifest>

Monodroid Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED] with specific permission

Recently I tried to add Map Fragment to my Monodroid app written with Xamarin + MvvmCross.
When I modify manifest in accordance with one of the mapping guides Google Maps in Monodroid Apps to:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionName="1.3.0.0" android:versionCode="1" package="MonoDroid.drdApp">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="MonoDroid.drdApp.permission.MAPS_RECEIVE" />
<permission android:name="MonoDroid.drdApp.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<application android:label="Droid App" android:icon="#drawable/icon">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my_valid_key_goes_here" />
</application>
</manifest>
I got the following error (runtime error):
Deployment failed because of an internal error: Unexpected install output: pkg: /data/local/tmp/MonoDroid.drdApp-Signed.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
I discovered that the manifest line which generates the error is:
<permission android:name="MonoDroid.drdApp.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
but this line is mentioned in almost every guide I found related to google maps for Android.
I'm not sure what this line does and not sure if app will work without it (currently it doesn't and this line is one of the suspects.
Could someone clarify how to deal with that manifest line?
I'm not 100% certain, but I suspect that the problem is in using a capital letter in your package name.
Try monodroid.drdapp instead - this may clear the error.
(Or better still - use the company name as part of the manifest)

Resources