question

IsaacRosenfeld-8140 avatar image
0 Votes"
IsaacRosenfeld-8140 asked YonglunLiu-MSFT commented

Xamarin android app not deploying.

[App2][1]I am unable to deploy or to archive it. But I'm not receiving any errors.
But when I removed the broadcast receiver (Receiver1.cs) it worked.
The code is located at:
[1]: https://github.com/KTechDev4213/App2
Thank You

dotnet-csharpdotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YonglunLiu-MSFT avatar image
0 Votes"
YonglunLiu-MSFT answered YonglunLiu-MSFT commented

Hello,

In my testing, After I removed the following code from AndroidManifest.xml:

<receiver android:name=".BootReceiver" android:enabled="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>


and added the following code in Receiver1.cs, the application could successfully deploy to my Android Emulator.

[BroadcastReceiver(Name = "com.my_app.app.BootBroadcast", Enabled = true, Exported = false)]
[IntentFilter(new[] { Intent.ActionBootCompleted })]
public class BootReceiver : BroadcastReceiver


The reason is that you need to set a value to the property export in using API 31 or above. and you can refer to this documentation Working with the Android Manifest to find this:

Xamarin.Android helps to minimize this difficulty by allowing you to add custom attributes to your classes, which will then be used to automatically generate the manifest for you. Our goal is that 99% of our users should never need to manually modify AndroidManifest.xml.

For this reason, we should try not to modify AndroidManifest.xml if we can.



Best Regards,

Alec Liu.




If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@IsaacRosenfeld-8140
I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.

0 Votes 0 ·