2023-02-14 Apps targeting Android 12 and higher are required to specify an explicit val
新建android项目,选择basic active一项,在跑模拟器的时候,报错。
解决方案:找到AndroidManifest.xml文件,在<activity 里面添加一行属性 android:exported="true"
详情Gpt给出的解决方案:
=======================================================================================================================================================
This error message indicates that you have an issue with the `AndroidManifest.xml` file in your Android app. It specifically states that if your app targets Android 12 (or higher), you must explicitly set the value for the `android:exported` attribute when you have an `intent-filter` defined for a component in your app.
(此错误消息表示您的Android应用程序中的“AndroidManifest.xml”文件存在问题。它特别指出,如果您的应用程序以Android 12(或更高版本)为目标,则当您为应用程序中的组件定义了“intent filter”时,必须显式设置“Android:exported”属性的值。)
The `android:exported` attribute specifies whether or not an activity, service, or broadcast receiver is exported, meaning that it can be started by other apps. If you have an `intent-filter` defined for a component, you must set `android:exported` to either `true` or `false` to specify if the component should be exported or not.
(“android:exported”属性指定是否导出活动、服务或广播接收器,这意味着它可以由其他应用程序启动。如果为组件定义了“intent filter”,则必须将“android:exported”设置为“true”或“false”,以指定是否应导出组件。)
Here's an example of how you can specify `android:exported` for an activity in your `AndroidManifest.xml`:
(下面是一个示例,说明如何为“AndroidManifest.xml”中的活动指定“android:exported”:)
```
<activity android:name=".MainActivity" android:exported="true"
> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
```
In the example above, `android:exported` is set to `true`, meaning that the MainActivity is exported and can be started by other apps. If you want to make the MainActivity not exported, you can set `android:exported` to `false`.
(在上面的示例中,“android:exported”设置为“true”,这意味着MainActivity已导出,可以由其他应用程序启动。如果要使MainActivity不导出,可以将“android:exported”设置为“false”。)
=======================================================================================================================================================
不得不说,Gpt确实厉害。