之前Android11中exported就需要加在AndroidMainifest.xml中的Activity中,今天偶然看见高德地图升级了SDK31,把自己的项目也升级一波。
    
     SDK31报错,SDK30正常运行,错误如下:
    
   
    Installation did not succeed.
    
    The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
    
    Installation failed due to: ‘null’
   
这咋整呢,看着是AndroidMainifest.xml这个有问题,网上搜了一波发现Android12对用户做了更加强的隐私保护,现在需要对Service和BroadCaseReceiver都添加exported。
    
     代码示范如下:
    
   
    
     Activity:
    
   
<activity
    android:name="com.ibptadb.activity.Main"
    android:exported="true"
    android:label="@string/app_name"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
    
     Service:
    
   
<service
    android:name="org.ibptadb.androidpn.client.NotificationService"
    android:enabled="true"
    android:exported="true"
    android:label="NotificationService">
    <intent-filter>
        <action android:name="org.NotificationService" />
    </intent-filter>
</service>
    
     BroadCaseReceiver:
    
   
<receiver android:name="com.DeletePicture"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.deletePicture" />
    </intent-filter>
</receiver>
加上之后,完美运行!
 
版权声明:本文为Motejia原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
