Android 12 Manifest

DavidSpecter 81 Reputation points
2021-11-16T09:24:54.847+00:00

Hi,
I'm trying to deploy my app targeting Android 12 but I continue receive this message

Severity Code Description Project File Line Suppression State Error ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1840069645.tmp/base.apk (at Binary XML file line #59): crc64a4414ef7b82e11fd.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

Here is my Manifest

<application android:label="testapp" android:icon="@mipmap/ic_launcher" android:allowBackup="true">  
          
        <provider android:authorities="eu.factory.testapp.fileprovider"  
                  android:exported="false"  
                  android:grantUriPermissions="true"  
                  android:name="androidx.core.content.FileProvider">  
            <meta-data android:name="com.google.android.geo.API_KEY" android:value="APIKEY"/>  
            <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />  
        </provider>  
  
        <uses-library android:name="org.apache.http.legacy" android:required="false" />  
          
        <provider android:name="androidx.core.content.FileProvider"  
                  android:authorities="eu.factory.testapp.fileprovider"  
                  android:exported="false"  
                  android:grantUriPermissions="true">  
  
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />  
        </provider>  
  
        <provider android:authorities="eu.factory.testapp.fileprovider"   
                  android:exported="false"   
                  android:grantUriPermissions="true"   
                  android:name="androidx.core.content.FileProvider">  
        </provider>  
 </application>  
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,337 questions
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,951 Reputation points
    2021-11-17T02:45:25.313+00:00

    Hello @DavidSpecter ,​

    Welcome to our Microsoft Q&A platform!

    Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present

    If the app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, we must explicitly declare the android:exported attribute for these components. Here is the related doc, you could refer to it: https://developer.android.com/about/versions/12/behavior-changes-12#exported

    Please try to add Exported =true for the MainActivity as below.

       [Activity(Label = "@string/app_name", Exported = true, ...)]  
       public class MainActivity : AppCompatActivity  
       {  
           ...  
       }  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, 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 person found this answer helpful.
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Sasanka MVS 1 Reputation point
    2022-03-15T11:04:29.563+00:00

    Hi @JarvanZhang

    As mentioned above, I have updated the Exported as true in the MainActivity.cs file, and I still have this error:

    Severity Code Description Project File Line Suppression State Error ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1840069645.tmp/base.apk (at Binary XML file line #59): crc64a4414ef7b82e11fd.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

    Please let me know if you need any additional information.

    Best Regards,
    Sasanka MVS

    0 comments No comments

  2. Suchith Madavu 1 Reputation point
    2022-04-21T06:59:10.657+00:00

    Does anyone got the solution. Even adding exported true to main activity or menifest throws same error

    0 comments No comments

  3. Victor Hugo Garcia Hernandez 1 Reputation point MVP
    2022-08-29T19:30:59.86+00:00

    I'm facing the exact same issue. Adding the Export = true did not work.

    Any workaround or potential solution?

    thanks in advance

    0 comments No comments

  4. Graham McKechnie 396 Reputation points
    2022-08-30T00:48:24.907+00:00

    You shouldn't have to add Export to the MainActivity Activity attribute as it is done automatically by Visual Studio. What version of Visual Studio are you using?

    What you should be checking is the generated manifest that you will find in obj\Release\120\android folder.

    e.g. <activity android:name="crc6401d9911e8382ecc6.MainActivity" android:exported="true" android:label="@ hide /app_name">

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.