UnsatisfiedLinkError: No implementation found for void mono.android.text.TextWatcherImplementor

UnsatisfiedLinkError: No implementation found for void mono.android.text.TextWatcherImplementor

我正在研究 Xamarin.Android 项目,在将所有库更新到最新版本和发布版本后,我遇到了这样一个例外:

07-26 09:17:08.681 9603-9603/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: xx.xx.xx, PID: xxxx
java.lang.UnsatisfiedLinkError: No implementation found for void mono.android.text.TextWatcherImplementor.n_beforeTextChanged(java.lang.CharSequence, int, int, int) (tried Java_mono_android_text_TextWatcherImplementor_n_1beforeTextChanged and Java_mono_android_text_TextWatcherImplementor_n_1beforeTextChanged__Ljava_lang_CharSequence_2III)
    at mono.android.text.TextWatcherImplementor.n_beforeTextChanged(Native Method)
    at mono.android.text.TextWatcherImplementor.beforeTextChanged(TextWatcherImplementor.java:41)
    at android.widget.TextView.sendBeforeTextChanged(TextView.java:10892)
    at android.widget.TextView.setText(TextView.java:6220)
    at android.widget.TextView.setText(TextView.java:6170)
    at android.widget.EditText.setText(EditText.java:146)
    at android.widget.TextView.setText(TextView.java:6127)
    at android.widget.TextView.setTransformationMethod(TextView.java:2755)
    at md5964384997be3f2086f58afbb264e9147.LoginView.n_onCreate(Native Method)
    at md5964384997be3f2086f58afbb264e9147.LoginView.onCreate(LoginView.java:31)
    at android.app.Activity.performCreate(Activity.java:7326)
    at android.app.Activity.performCreate(Activity.java:7317)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3235)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:6986)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

我添加了这样的方法

public void Include(TextView text)
    {
        text.Text = $"{text.Text}";
        text.AfterTextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.TextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.BeforeTextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.Hint = $"{text.Hint}";
    }

    public void Include(EditText text)
    {
        text.Text = $"{text.Text}";
        text.AfterTextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.TextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.BeforeTextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.Hint = $"{text.Hint}";
    }

    public void Include(Android.Support.Design.Widget.TextInputEditText text)
    {
        text.Text = $"{text.Text}";
        text.AfterTextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.TextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.BeforeTextChanged += (sender, args) => text.Text = $"{text.Text}";
        text.Hint = $"{text.Hint}";
    }

LinkerPleaseInclude 但它仍然无济于事。有什么想法吗?

我试图清除所有内容(bin、obj、app、visualstudio 等)

这是一个已知问题。有关详细信息,请参阅以下问题:

https://github.com/xamarin/xamarin-android/issues/3263#issuecomment-514046705

  1. 创建 custom linker configuration
  2. 添加以下内容
<linker>
  <assembly fullname="Mono.Android">
    <type fullname="Android.Text.ITextWatcherInvoker" preserve="all" />
  </assembly>
</linker>

虽然这是一个临时修复,但我们正在努力在未来的版本中解决它。