patriczi
patriczi

Reputation: 51

Xamarin.Android - problems whith change targetSdkVersion

when i try change targetSdkVersion in my Xamarin.Android project from level 30 to higher level 31/33, I get errors.

Severity    Code    Description Project File    Line    Suppression State
Error       
(my-path).Android\obj\Debug\130\lp\104\jl\AndroidManifest.xml Warning:
    Namespace 'com.google.firebase.components' used in: AndroidManifest.xml, AndroidManifest.xml.
(my-path).Android\obj\Debug\130\lp\116\jl\AndroidManifest.xml Warning:
    Namespace 'com.google.android.gms.base' used in: AndroidManifest.xml, AndroidManifest.xml.
(my-path).Android\obj\Debug\130\lp\103\jl\AndroidManifest.xml Warning:
    Namespace 'com.google.firebase' used in: AndroidManifest.xml, AndroidManifest.xml.
(my-path).Android\obj\Debug\130\lp\102\jl\AndroidManifest.xml Warning:
    Namespace 'com.google.firebase.icing' used in: AndroidManifest.xml, AndroidManifest.xml.
(my-path).Android\obj\Debug\130\lp\117\jl\AndroidManifest.xml Warning:
    Namespace 'com.google.android.gms.common' used in: AndroidManifest.xml, AndroidManifest.xml.
(my-path).Android\obj\Debug\130\lp\119\jl\AndroidManifest.xml Warning:
    Namespace 'com.google.android.gms.tasks' used in: AndroidManifest.xml, AndroidManifest.xml.

    android:exported needs to be explicitly specified for element <activity#crc64a3cec488f879dbb8.WebAuthenticationCallbackActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
Directory 'obj\Debug\130\lp\104' is from 'Xamarin.Firebase.Components.dll'.
Directory 'obj\Debug\130\lp\116' is from 'Xamarin.GooglePlayServices.Base.dll'.
Directory 'obj\Debug\130\lp\103' is from 'Xamarin.Firebase.Common.dll'.
Directory 'obj\Debug\130\lp\102' is from 'Xamarin.Firebase.AppIndexing.dll'.
Directory 'obj\Debug\130\lp\117' is from 'Xamarin.GooglePlayServices.Basement.dll'.
Directory 'obj\Debug\130\lp\119' is from 'Xamarin.GooglePlayServices.Tasks.dll'.    

Severity    Code    Description Project File    Line    Suppression State
Error       android:exported needs to be explicitly specified for element <service#crc6494e14b9856016c30.PNFirebaseMessagingService>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.   
Severity    Code    Description Project File    Line    Suppression State
Error       android:exported needs to be explicitly specified for element <receiver#crc64df999be563077fc4.BootReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

I changed compile using Android version(Target Framework) to Android 13.0. I updated my nugets but it dosen't work. The error suggests adding android:exported when i add this and set it to true or false in my AndroidManifest.xml I got the same errors. My AndroidManifest.xml looks like that:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="mypackage" android:versionName="0.1.19" android:versionCode="46">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
    <application android:icon="@drawable/icon" android:label="myName" android:largeHeap="@bool/largeheap">
        <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/facebook_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>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
    <uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
    <uses-permission android:name="android.permission.CAPTURE_SECURE_VIDEO_OUTPUT" />
    <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
    <queries>
        <intent>
            <action android:name="android.support.customtabs.action.CustomTabsService" />
        </intent>
    </queries>
</manifest>

What should I do to get rid of these bugs?

Upvotes: 1

Views: 1026

Answers (1)

Anand
Anand

Reputation: 1959

You need to navigate inside Project.Android-->Obj--> Debug. There you can see one AndroidManifest File. Open it and you can see some tags about

WebAuthenticationCallbackActivity, BootReceiver

Add android:exported=true or false and Paste thease two tags into your AndroidManifest inside visual studio soultion.

You have one more error about PNFirebaseMessagingService. For that open the class and change [Service] to [Service(Exported = true)] on top of the service class.

Upvotes: 2

Related Questions