xamarin表单地图崩溃在路径:DexPathList上找不到类“ com.google.android.gms.dynamic.zza”

时间:2019-12-16 15:01:21

标签: c# xamarin.forms xamarin.android maps

Xamarin.Forms.Maps导致Android应用崩溃。

这是我在Xaml中使用它的方式:

<maps:Map HeightRequest="{Binding MapHeight}"
          VerticalOptions="{Binding MapVerticalOptions}"
           IsShowingUser="true"
           MapType="Hybrid"
           HasScrollEnabled="true"
           HasZoomEnabled="true">
 </maps:Map>

但是一旦我打开包含地图的页面,输出中就会出现以下错误:

"Didn't find class \"com.google.android.gms.dynamic.zza\" on path: DexPathList[[zip file \"/system/framework/org.apache.http.legacy.boot.jar\", zip file \"/data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/base.apk\"],nativeLibraryDirectories=[/data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/lib/x86, /data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/base.apk!/lib/x86, /system/lib]]"   

这是完整的崩溃数据:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/dynamic/zza; ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamic.zza" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/base.apk"],nativeLibraryDirectories=[/data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/lib/x86, /data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/base.apk!/lib/x86, /system/lib]]
[MonoDroid]    --- End of inner exception stack trace ---
[MonoDroid]   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <42bcf67b56bc4c909c2a5edee682522b>:0 
[MonoDroid]   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/vsts/agent/2.158.0/work/1/s/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:444 
[MonoDroid]   at Android.Runtime.JNIEnv.FinishCreateInstance (System.IntPtr instance, System.IntPtr jclass, System.IntPtr constructorId, Android.Runtime.JValue* constructorParameters) [0x00008] in /Users/vsts/agent/2.158.0/work/1/s/src/Mono.Android/Android.Runtime/JNIEnv.cs:367 
[MonoDroid]   at Android.Gms.Maps.MapView..ctor (Android.Content.Context context) [0x000c4] in <0ef98d0b7df944fb8f20d9e078937bf5>:0 
[MonoDroid]   at Xamarin.Forms.Maps.Android.MapRenderer.CreateNativeControl () [0x00006] in <fa3ac64c5c6e4bdab97ed1b74d8ae8bb>:0 
[MonoDroid]   at Xamarin.Forms.Maps.Android.MapRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x0000e] in <fa3ac64c5c6e4bdab97ed1b74d8ae8bb>:0 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000b8] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:231 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:128 
[MonoDroid]   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:344 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000af] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00139] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:440 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:128 
[MonoDroid]   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:344 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000af] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00139] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:440 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:128 
[MonoDroid]   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:344 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000af] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00139] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:440 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234 
[MonoDroid]   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:128 
[MonoDroid]   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager, Android.Content.Context context) [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:391 
[MonoDroid]   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:56 
[MonoDroid]   at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00020] in <fefee6c2c695459088a9df092723e052>:0 
[MonoDroid]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.58(intptr,intptr,intptr,intptr,intptr)
[MonoDroid]   --- End of managed Java.Lang.NoClassDefFoundError stack trace ---
[MonoDroid] java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/dynamic/zza;
[MonoDroid]     at java.lang.Class.classForName(Native Method)
[MonoDroid]     at java.lang.Class.forName(Class.java:453)
[MonoDroid]     at md58432a647068b097f9637064b8985a5e0.FragmentContainer.n_onCreateView(Native Method)
[MonoDroid]     at md58432a647068b097f9637064b8985a5e0.FragmentContainer.onCreateView(FragmentContainer.java:33)
[MonoDroid]     at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
[MonoDroid]     at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
[MonoDroid]     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
[MonoDroid]     at android.os.Handler.handleCallback(Handler.java:873)
[MonoDroid]     at android.os.Handler.dispatchMessage(Handler.java:99)
[MonoDroid]     at android.os.Looper.loop(Looper.java:193)
[MonoDroid]     at android.app.ActivityThread.main(ActivityThread.java:6669)
[MonoDroid]     at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid]     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[MonoDroid]     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[MonoDroid] Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamic.zza" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/base.apk"],nativeLibraryDirectories=[/data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/lib/x86, /data/app/com.company.app-LKgNhdSyL2tSQdIvKMSIKg==/base.apk!/lib/x86, /system/lib]]
[MonoDroid]     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
[MonoDroid]     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[MonoDroid]     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[MonoDroid]     ... 21 more
[MonoDroid] 

我尝试使用Android 10、8和7进行编译,但结果相同。 我正在使用 Xamarin.Form 4.4.0.991265 Xamarin.Forms.Maps 4.4.0.991265

1 个答案:

答案 0 :(得分:0)

我用Xamarin.Form 4.4.0.991265Xamarin.Forms.Maps 4.4.0.991265.进行测试

然后我在一个Android 8.1模拟器中运行我的演示,它正常运行。

这是我的代码。

<local:CustomMap x:Name="customMap" 
                     MapType="Hybrid" 
                     WidthRequest="{x:Static local:App.ScreenWidth}" 
                     HeightRequest="{x:Static local:App.ScreenHeight}" 
                     HasScrollEnabled="true"
                     HasZoomEnabled="true"
                     />

CustomMap的代码。

using Xamarin.Forms.Maps;

namespace CustomRenderer
 {
public class CustomMap : Map
{
    public List<CustomPin> CustomPins { get; set; }
}
}

这是我正在运行的屏幕截图。

enter image description here

这是我的演示,您可以下载它进行测试。

https://github.com/851265601/Xamarin.Forms.MapsDemo