简体   繁体   English

Xamarin 使用 CallRedirectionService 抛出 Java.Lang.ClassNotFoundException

[英]Xamarin throws Java.Lang.ClassNotFoundException using CallRedirectionService

I created a new Mobile App Xamarin.Forms project using the blank template for this example.我使用此示例的空白模板创建了一个新的移动应用 Xamarin.Forms 项目。 I am trying to use CallRedirectionService in my app, but the following exception is thrown.我正在尝试在我的应用程序中使用 CallRedirectionService,但引发了以下异常。

Java.Lang.ClassNotFoundException: crc64bf934172c93e128d.MyCallService ---> Java.Lang.NoClassDefFoundError: Failed resolution of: Landroid/telecom/CallRedirectionService; Java.Lang.ClassNotFoundException:crc64bf934172c93e128d.MyCallService ---> Java.Lang.NoClassDefFoundError:解析失败:Landroid/telecom/CallRedirectionService; ---> Java.Lang.ClassNotFoundException: Didn't find class "android.telecom.CallRedirectionService" on path: DexPathList[[zip file "/data/app/com.companyname.xam-8bL_MB0IWItrj3Z69Zwvtw==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.xam-8bL_MB0IWItrj3Z69Zwvtw==/lib/x86, /data/app/com.companyname.xam-8bL_MB0IWItrj3Z69Zwvtw==/base.apk!/lib/x86, /system/lib]] ---> Java.Lang.ClassNotFoundException:在路径上找不到类“android.telecom.CallRedirectionService”:DexPathList[[zip file“/data/app/com.companyname.xam-8bL_MB0IWItrj3Z69Zwvtw==/base.apk” ],nativeLibraryDirectories=[/data/app/com.companyname.xam-8bL_MB0IWItrj3Z69Zwvtw==/lib/x86, /data/app/com.companyname.xam-8bL_MB0IWItrj3Z69Zwvtw==/base.apk!/lib/x86, /lib/x86 /lib]]

using Android.Telecom;
using Xamarin.Forms;    
namespace xam
    {
        public class MyCallService : CallRedirectionService
        {
            public override void OnPlaceCall(Android.Net.Uri handle, PhoneAccountHandle initialPhoneAccount, bool allowInteractiveResponse)
            {
                //throw new NotImplementedException();
            }
        }
        public partial class MainPage : ContentPage
        {
            public MainPage()
            {
                var callCervice = new MyCallService();
                InitializeComponent();
            }
        }
    }

How can i solve it, since other service doesnt throw any exceptions我该如何解决,因为其他服务不会抛出任何异常

eg例如

public class CallPreventer : InCallService
{
    public override void OnCallAdded(Call call)
    {
        call.Disconnect();
        base.OnCallAdded(call);
    }
}

Android options安卓选项

Exception例外

From the screen shots it looks like this code is part of the .NET standard assembly (shared project) which won't reference Mono Android.从屏幕截图看来,此代码是 .NET 标准程序集(共享项目)的一部分,不会引用 Mono Android。 Instead, try using the Xamarin Forms Dependency Service to invoke the platform-specific things you want from shared code.相反,请尝试使用Xamarin Forms Dependency Service从共享代码中调用特定于平台的内容。 See my recreation of your code here .在此处查看我对您的代码的重新创建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM