Xamarin.Forms更改AndroidManifest.xml导致错误:没有兼容的代码在线程上运行

想在APP中加一个打开摄像头的功能,按照该博主的方法:https://blog.csdn.net/zhenweied09/article/details/82287761

设置好后,再运行就出现上图的错误,于是查找原因,定位到是更改AndroidManifest.xml文件导致的,

需要把android.support.v4.content.FileProvider替换为androidx.core.content.FileProvider即可

XML 复制代码
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.robotdemoapp">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
    <application android:label="RobotDemoApp.Android" android:theme="@style/MainTheme">
      <!-- new add camera root 2023-10-30 https://blog.csdn.net/zhenweied09/article/details/82287761 -->
      <!-- 为什么报:没有兼容的代码在线程上运行?把android.support.v4.content.FileProvider替换为androidx.core.content.FileProvider -->
      <provider android:name="androidx.core.content.FileProvider"
                android:authorities="${applicationId}.fileprovider"
                android:exported="false"
                android:grantUriPermissions="true">
                <meta-data android:name="android.support.FILE_PROVIDER_PATHS" 
                           android:resource="@xml/file_paths">
                </meta-data>
      </provider>
    </application>
  
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- new add camera root 2023-10-30 https://blog.csdn.net/zhenweied09/article/details/82287761 -->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />


  <!--
    如果项目的目标 Android 版本设置为 Android 11 (R API 30) 或更高版本,则必须使用使用 Android 包可见性要求的查询更新 Android 清单。
    在 Platforms/Android/AndroidManifest.xml 文件中,在 节点manifest中添加以下queries/intent节点:
  -->
  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="http"/>
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="https"/>
    </intent>
  </queries>
  
</manifest>
相关推荐
鹏晨互联1 天前
【Compose vs XML:边框内外间距的实现对比】
android·xml
鹏晨互联3 天前
Jetpack Compose vs XML:fillMaxSize、fillMaxHeight、fillMaxWidth 全面对比
android·xml
如果'\'真能转义说4 天前
OOXML 文档格式剖析:哈希、ZIP结构与识别
xml·算法·c#·哈希算法
ZC跨境爬虫5 天前
跟着 MDN 学 HTML day_34:(深入XML 中的 CDATASection 接口)
xml·前端·html·html5·媒体
hmywillstronger5 天前
【Python】从SAP2000 XML截面库提取数据到Excel
xml·python·excel
Boop_wu5 天前
[Mybatis] XML 方式实现 MP 自定义 SQL + 条件构造器
xml·sql·mybatis
曹牧5 天前
Oracle:将包含属性(Attributes)的 XML 数据解析为表格数据
xml·数据库·oracle
阿维的博客日记6 天前
传统 Spring XML 配置 vs Spring Boot Starter 对比文档
xml·spring boot·spring
Cx330❀8 天前
Qt 入门指南:从零搭建开发环境到第一个图形界面程序
xml·大数据·开发语言·网络·c++·人工智能·qt