gpt4 book ai didi

android - Xamarin Media 插件不适用于 Android

转载 作者:行者123 更新时间:2023-11-30 00:08:22 24 4
gpt4 key购买 nike

我已经安装了插件 Xam.Plugin.Media。该插件在 IOS 上运行良好,但在 Andorid 上,应用程序一启动就崩溃。

我按照安装插件后的readme.txt,所以我的文件是:

MainActivity.cs:

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using FFImageLoading.Forms.Droid;

namespace SgatMobileV2.Droid {
[Activity(Label = "SgatMobileV2", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity {
protected override void OnCreate(Bundle bundle) {
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

base.OnCreate(bundle);

global::Xamarin.Forms.Forms.Init(this, bundle);

CachedImageRenderer.Init(enableFastRenderer: true); // Inizializza il plugin FFImageLoading

LoadApplication(new App());
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, global::Android.Content.PM.Permission[] grantResults) {
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}

资源/xml/file_paths.xml:

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

AndroidManifest.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="it.volos.SgatMobile" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:label="SgatMobileV2.Android" android:icon="@drawable/icon">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="it.volos.SgatMobile.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>

但是应用启动后,会触发这个错误:

System.NullReferenceException: Object reference not set to an instance of an object.

谁能帮帮我?

谢谢!

最佳答案

看起来在清理解决方案关闭 Visual Studio删除 obj 和 bin 文件夹 之后,我的项目再次正常运行。 ...

我还将 file_paths.xml 的构建操作设置为 AndroidResource

希望对您有所帮助。

关于android - Xamarin Media 插件不适用于 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48587281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com