0

我正在使用 d8+r8+Multi-Dex 来部署我的 Xamarin Forms 应用程序。但是,启用 r8 时,我遇到了一些奇怪的异常。我检查了调试模式,我收到了这个奇怪的错误。我还配置了 proguard 文件来免除一些文件,但它没有帮助。 Java.Lang.NoSuchMethodError

06-17 19:06:08.090 D/Mono    (31705): Assembly Loader probing location: '//Facades/Xamarin.Forms.Platform.Android.AppLinks.exe'.
06-17 19:06:08.195 D/Mono    (31705): DllImport searching in: '__Internal' ('(null)').
06-17 19:06:08.195 D/Mono    (31705): Searching for 'java_interop_jnienv_call_static_int_method_a'.
06-17 19:06:08.195 D/Mono    (31705): Probing 'java_interop_jnienv_call_static_int_method_a'.
06-17 19:06:08.196 D/Mono    (31705): Found as 'java_interop_jnienv_call_static_int_method_a'.
06-17 19:06:08.322 D/Mono    (31705): DllImport searching in: '__Internal' ('(null)').
06-17 19:06:08.322 D/Mono    (31705): Searching for 'java_interop_jnienv_call_nonvirtual_int_method_a'.
06-17 19:06:08.322 D/Mono    (31705): Probing 'java_interop_jnienv_call_nonvirtual_int_method_a'.
06-17 19:06:08.322 D/Mono    (31705): Found as 'java_interop_jnienv_call_nonvirtual_int_method_a'.
06-17 19:06:08.389 I/FA      (31705): Tag Manager is not found and thus will not be used
06-17 19:06:08.391 D/OpenGLRenderer(31705): HWUI GL Pipeline
06-17 19:06:08.398 E/FA      (31705): Missing google_app_id. Firebase Analytics disabled. See 
06-17 19:06:08.560 D/Mono    (31705): Requesting loading reference 9 (of 13) of /storage/emulated/0/Android/data/com.AZEE.wquran/files/.__override__/Xamarin.AndroidX.Fragment.dll
06-17 19:06:08.560 D/Mono    (31705): Loading reference 9 of /storage/emulated/0/Android/data/com.AZEE.wquran/files/.__override__/Xamarin.AndroidX.Fragment.dll asmctx DEFAULT, looking for Xamarin.AndroidX.Lifecycle.LiveData.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
06-17 19:06:08.560 D/Mono    (31705): Assembly Ref addref Xamarin.AndroidX.Fragment[0xe9e72860] -> Xamarin.AndroidX.Lifecycle.LiveData.Core[0xe9e72aa0]: 2
06-17 19:06:08.652 D/Mono    (31705): DllImport searching in: '__Internal' ('(null)').
06-17 19:06:08.652 D/Mono    (31705): Searching for 'java_interop_jnienv_call_object_method'.
06-17 19:06:08.652 D/Mono    (31705): Probing 'java_interop_jnienv_call_object_method'.
06-17 19:06:08.652 D/Mono    (31705): Found as 'java_interop_jnienv_call_object_method'.
06-17 19:06:08.825 W/DynamiteModule(31705): Local module descriptor class for com.google.android.gms.ads.dynamite not found.
**Java.Lang.NoSuchMethodError:** 'no non-static method "Landroidx/fragment/app/FragmentTransaction;.add(ILandroidx/fragment/app/Fragment;)Landroidx/fragment/app/FragmentTransaction;"'

Thread started: <Thread Pool> #10
Thread started: <Thread Pool> #11
Thread finished: <Thread Pool> #7
The thread 0x7 has exited with code 0 (0x0).

"<threadpool thread>"
"<threadpool thread>"

"<unnamed thread>"  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception) <0x00012>
  at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Diagnostics/Debugger.cs:125
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.63 (intptr,intptr) [0x00020] in <eaa205f580954a64824b74a79fa87c62>:0
  at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.63 (intptr,intptr) [0x00030] in <eaa205f580954a64824b74a79fa87c62>:0

保护文件

-dontwarn java.lang.invoke.**
-keep public class * implements androidx.versionedparcelable.VersionedParcelable
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**

-keep class android.support.V7.**
-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.**
-keep class android.support.v4.widget.Space { *; }
-dontwarn android.support.v4.widget.Space

-keep class MediaManager.CrossMediaManager.**
-keep class android.support.v4.media.MediaBrowserCompat
-keep class android.support.v4.media.**

-keep class androidX.appCompat.widget.**
-keep class Plugin.InAppBilling.**
-keep class Plugin.InAppBilling.InAppBillingImplementation.**
4

1 回答 1

-2

我从 proguard 文件中删除了最后 6 行,它起作用了。

-keep class MediaManager.CrossMediaManager.**
-keep class android.support.v4.media.MediaBrowserCompat
-keep class android.support.v4.media.**

-keep class androidX.appCompat.widget.**
-keep class Plugin.InAppBilling.**
-keep class Plugin.InAppBilling.InAppBillingImplementation.**
于 2020-06-21T09:29:33.440 回答