-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActivityAttribute.MainActivity should set exported=true #6196
Comments
…ctivities Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ Fixes: dotnet#6196 > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" android:exported="true" /> <category android:name="android.intent.category.LAUNCHER" android:exported="true" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…ctivities Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ Fixes: dotnet#6196 > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…6212) Fixes: #6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…6212) Fixes: #6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…otnet#6212) Fixes: dotnet#6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…6212) Fixes: #6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
Hi, I have a legacy app that is throwing this exception: Any tips on how to fix this? I can see the |
The @marcelojaf if that doesn't fix it, can you file a new issue? Include the contents of |
Thank you very much for the answer. MainActivity.cs:
and MainApplication.cs:
Here's the
If I manually include the Thank you again |
So, I saw the Microsoft docs for Firebase Cloud Messaging and see that the client is using a NuGet Packkage Plugin.FirebaseCloudMessaging which is not updated since March 2020 and is not on the Microsoft docs. I will fork and try to remove this plugin and use Xamarin.Firebase.Messaging as described on the documentation. I will post the result here in case other fellow developer face the same issue. |
Hi @marcelojaf , 'Exported = true' didn't solve my problem Thanks |
I followed this guy tip |
Thanks a lot! it works now |
Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/
The short version is that many apps may need to update their
[Activity]
attribute usage to explicitly setActivityAttribute.Exported
.However, we added
ActivityAttribute.MainLauncher
, which is also used in our templates:https://github.com/xamarin/xamarin-android/blob/f7d32102cc3ada67aa12cc0beed2cf97226f41b3/src/Microsoft.Android.Templates/android/MainActivity.cs#L8
We should update our
AndroidManifest.xml
generation & related code so that whenMainLauncher=true
, we also automatically setexported=true
.The text was updated successfully, but these errors were encountered: