gpt4 book ai didi

android - 谷歌地图在 Android 10 上崩溃

转载 作者:行者123 更新时间:2023-11-30 04:58:32 26 4
gpt4 key购买 nike

我已经在 Android 上实现了 Google map ,在 Android Pie 之前运行良好。但是在 10 日,我遇到了以下崩溃。

com.google.android.apps.gmm.map.util.jni.zza: Exception while extracting native library.
at com.google.android.apps.gmm.map.util.jni.NativeHelper.safeLoadLibrary(NativeHelper.java:53)
at com.google.android.apps.gmm.map.util.jni.NativeHelper.ensureLibraryLoaded(NativeHelper.java:17)
at com.google.android.apps.gmm.map.internal.store.diskcache.NativeSqliteDiskCacheImpl.<clinit>(NativeSqliteDiskCacheImpl.java:141)
at com.google.android.apps.gmm.map.internal.store.diskcache.NativeSqliteDiskCacheImpl.createOrOpenDatabase(NativeSqliteDiskCacheImpl.java:4)
at com.google.android.apps.gmm.map.internal.store.diskcache.zzf.zza(SqliteDiskCache.java:6)
at com.google.android.apps.gmm.map.internal.store.diskcache.zzg.zzc(SqliteDiskCacheProvider.java:104)
at com.google.android.apps.gmm.map.internal.store.diskcache.zzg.zza(SqliteDiskCacheProvider.java:31)
at com.google.android.apps.gmm.map.internal.store.zzbe.zza(TileStoreFactory.java:97)
at com.google.android.apps.gmm.map.internal.store.zzbe.zza(TileStoreFactory.java:67)
at com.google.android.libraries.maps.bl.zzex.zza(TileOverlayFactory.java:56)
at com.google.android.libraries.maps.bl.zzdq.zza(PhoenixGoogleMapActivityEnvironment.java:127)
at com.google.android.libraries.maps.bl.zzdq.zzd(PhoenixGoogleMapActivityEnvironment.java:210)
at com.google.android.libraries.maps.av.zzg.zza(MapContainer.java:26)
at com.google.android.libraries.maps.gu.zzat.zza(RendererFactoryImpl.java:177)
at com.google.android.libraries.maps.it.zzav.zza(GoogleMapImpl.java:59)
at com.google.android.libraries.maps.it.zzci.zza(MapFragmentDelegateImpl.java:3)
at com.google.android.libraries.maps.it.zzcg.zza(MapFragmentDelegateImpl.java:15)
at com.google.android.libraries.maps.SupportMapFragment$zza.onCreateView(SupportMapFragment.java:15)
at com.google.android.gms.dynamic.zae.zaa(com.google.android.gms:play-services-base@@17.1.0:4)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.zaa(com.google.android.gms:play-services-base@@17.1.0:9)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreateView(com.google.android.gms:play-services-base@@17.1.0:25)
at com.google.android.libraries.maps.SupportMapFragment.onCreateView(SupportMapFragment.java:34)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.ensureInflatedFragmentView(FragmentManagerImpl.java:1138)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:851)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1133)
at androidx.fragment.app.FragmentManagerImpl.addFragment(FragmentManagerImpl.java:1393)
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManagerImpl.java:3205)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1061)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126)
at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:95)

如果需要任何其他详细信息,我将很乐意提供帮助。非常感谢任何有关此事的帮助或提示。

编辑-代码部分

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val mapFragment = childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync {
map = it
it.setLocationSource(LocationSource)
}

}

布局

<layout xmlns:android="http://schemas.android.com/apk/res/android">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment
android:id="@+id/map"
android:name="com.google.android.libraries.maps.SupportMapFragment"
class="com.google.android.libraries.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

</fragment>
<ImageView
android:id="@+id/my_loc_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:padding="10dp"
android:layout_gravity="bottom|end"
android:src="@drawable/ic_my_location"/>
<ImageView
android:id="@+id/menu_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:padding="10dp"
android:layout_gravity="top|start"
android:src="@drawable/ic_hamburger"/>
</FrameLayout>
</layout>

解决方法经过无数次的尝试和错误,发现错误是构建工具版本将 com.android.tools.build:gradle:3.5.1 更改为 com.android.tools.build:gradle:3.3.1修复它。

最佳答案

用下面的代码替换你的 XML,

<layout xmlns:android="http://schemas.android.com/apk/res/android">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Change start-->
<FrameLayout
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

</FrameLayout>
<!-- Change end-->
<ImageView
android:id="@+id/my_loc_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:padding="10dp"
android:layout_gravity="bottom|end"
android:src="@drawable/ic_my_location"/>
<ImageView
android:id="@+id/menu_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:padding="10dp"
android:layout_gravity="top|start"
android:src="@drawable/ic_hamburger"/>
</FrameLayout>
</layout>

你的 fragment 编码部分,

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

val smf = SupportMapFragment.newInstance()
childFragmentManager.beginTransaction().replace(R.id.map, smf).commit()
smf.getMapAsync({
Toast.makeText(activity,"Map Ready",Toast.LENGTH_SHORT).show()
})
}

祝你今天愉快。

关于android - 谷歌地图在 Android 10 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58708294/

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