Xam.Plugin.Media错误Xamarin表格

时间:2018-08-17 04:59:40

标签: android xamarin xamarin.forms

我正在使用 Xam.Plugin.Media 捕获图像。我遵循了有关如何设置 Android File Provider 的步骤,但是当我添加 XML文件时,我的应用程序将无法启动。我遇到错误

  

未处理的异常:Java.Lang.RuntimeException:无法启动活动   ComponentInfo {com.micromax.TBSApp / md504a41c7e901c515e3da12260620b83ea.MainActivity}:   java.lang.NullPointerException:尝试调用虚拟方法'void   android.support.v7.widget.ContentFrameLayout.setAttachListener(android.support.v7.widget.ContentFrameLayout $ OnAttachListener)'   在空对象引用上

Android Manifest.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.micromax.TBSApp" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-feature android:name="android.hardware.location" android:required="false" />
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />
    <uses-feature android:name="android.hardware.location.network" android:required="false" />
    <application android:label="TBSApp.Android">
    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.android.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>
</manifest>

file_paths.xml-(生成操作:Android资源)

<?xml version="1.0" encoding="utf-8" ?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <external-path name="my_images" path="Android/data/com.example.package.name/files/Pictures" />
</paths>

1 个答案:

答案 0 :(得分:0)

尝试删除bin和obj,然后重新加载您的项目。