将targetSdkVersion 30更改为31错误离子 cordova

sqserrrh  于 2022-11-15  发布在  其他
关注(0)|答案(1)|浏览(167)

将targetSdkVersion更改为31后,我收到以下错误:

Task :app:processReleaseMainManifest FAILED
        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.

我试过添加,但仍然不起作用

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
            <application android:exported="true" />
</edit-config>
11dmarpk

11dmarpk1#

用于修复它的脚本:

echo "plugin explicit export:android for targetSdk 31..."
# LINUX #
sed -i -e 's/android:name="nl.xservices.plugins.ShareChooserPendingIntent" android:enabled="true"/android:name="nl.xservices.plugins.ShareChooserPendingIntent" android:exported="false" android:enabled="true"/g' plugins/cordova-plugin-x-socialsharing/plugin.xml
sed -i -e 's/android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop">/android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop" android:exported="false">/g' plugins/cordova-plugin-fcm-with-dependecy-updated/plugin.xml
sed -i -e 's/android:stopWithTask="false">/android:stopWithTask="false" android:exported="false">/g' plugins/cordova-plugin-fcm-with-dependecy-updated/plugin.xml

sed -i -e 's/android:name="nl.xservices.plugins.ShareChooserPendingIntent" android:enabled="true"/android:name="nl.xservices.plugins.ShareChooserPendingIntent" android:exported="false" android:enabled="true"/g' node_modules/cordova-plugin-x-socialsharing/plugin.xml
sed -i -e 's/android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop">/android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop" android:exported="false">/g' node_modules/cordova-plugin-fcm-with-dependecy-updated/plugin.xml
sed -i -e 's/android:stopWithTask="false">/android:stopWithTask="false" android:exported="false">/g' node_modules/cordova-plugin-fcm-with-dependecy-updated/plugin.xml

echo "fixing social sharing for android 12..."
#LINUX#
sed -i -e 's/final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT);/int pendingIntentValueFLAG = 0; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { pendingIntentValueFLAG = PendingIntent.FLAG_MUTABLE; } else { pendingIntentValueFLAG = PendingIntent.FLAG_UPDATE_CURRENT; } final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, pendingIntentValueFLAG);/g' plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java
sed -i -e 's/final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT);/int pendingIntentValueFLAG = 0; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { pendingIntentValueFLAG = PendingIntent.FLAG_MUTABLE; } else { pendingIntentValueFLAG = PendingIntent.FLAG_UPDATE_CURRENT; } final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, pendingIntentValueFLAG);/g' node_modules/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java

相关问题