Java 为什么不是';图中没有显示地图碎片吗?
所以我试着做一个包含谷歌地图片段的简单应用程序。我从安卓工作室的预设开始。从新开始,显示工具栏,但不显示地图片段。下面,您将看到我的代码和堆栈跟踪: 活动映射.xmlJava 为什么不是';图中没有显示地图碎片吗?,java,android,google-maps,android-fragments,Java,Android,Google Maps,Android Fragments,所以我试着做一个包含谷歌地图片段的简单应用程序。我从安卓工作室的预设开始。从新开始,显示工具栏,但不显示地图片段。下面,您将看到我的代码和堆栈跟踪: 活动映射.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.androi
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="1080dp"
android:layout_height="1920dp"
tools:context=".MapsActivity">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="1720dp"
tools:context="com.example.testingmapingmarker23.MapsActivity"
/>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testingmapingmarker23">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value=" AIz...." />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="1080dp"
android:layout_height="1920dp"
tools:context=".MapsActivity">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="1720dp"
tools:context="com.example.testingmapingmarker23.MapsActivity"
/>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testingmapingmarker23">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value=" AIz...." />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
堆栈跟踪
/com.example.testingmapingmarker23 W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000023/n/armeabi-v7a
07-05 23:22:08.294 21301-21845/com.example.testingmapingmarker23 W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000023/n/armeabi
07-05 23:22:08.296 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20: <core_glEGLImageTargetTexture2DOES:4548>: GL_INVALID_VALUE
07-05 23:22:08.298 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20: <core_glEGLImageTargetTexture2DOES:4548>: GL_INVALID_VALUE
07-05 23:22:08.298 21301-21849/com.example.testingmapingmarker23 E/GLConsumer: [SurfaceTexture-0-21301-0] bindTextureImage: error binding external image: 0x501
07-05 23:22:08.343 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20: <core_glEGLImageTargetTexture2DOES:4548>: GL_INVALID_VALUE
07-05 23:22:08.345 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20: <core_glEGLImageTargetTexture2DOES:4548>: GL_INVALID_VALUE
/com.example.testingmapingmarker23 W/System:ClassLoader引用的未知路径:/data/data/com.google.android.gms/app_chimera/m/00000023/n/armeabi-v7a
07-05 23:22:08.294 21301-21845/com.example.testingmapingmarker23 W/System:ClassLoader引用的未知路径:/data/data/com.google.android.gms/app_chimera/m/00000023/n/armeabi
07-05 23:22:08.296 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20::GL_无效值
07-05 23:22:08.298 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20::GL_无效值
07-05 23:22:08.298 21301-21849/com.example.testingmapingmarker23 E/GLConsumer:[SurfaceTexture-0-21301-0]bindTextureImage:绑定外部映像时出错:0x501
07-05 23:22:08.343 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20::GL_无效值
07-05 23:22:08.345 21301-21849/com.example.testingmapingmarker23 W/Adreno-ES20::GL_无效值
这一点反复出现。我在Android 6.0.1上使用OnePlus 1,并显示了API 23。应用程序运行,但不显示地图片段 对于布局:
如果您正在使用自定义的工具栏,最好将样式更改为
无操作栏
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
对于那个地图片段
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
这将简单地将工具栏作为地图片段放置在顶部和下方
现在,对于未显示的地图:
你有没有在你的应用程序中加入谷歌播放服务的依赖项
还要将其添加到您权限上方的清单文件中
<permission
android:name="your_package_name.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
抱歉,我无法发表评论,所以发布了一个答案
希望能有帮助 这是因为地图不应该是整个屏幕。工具栏也应该有一个位置。然后使用线性布局。。。没有理由硬编码一个元素的大小,我改变了它,但错误保持不变same@cricket_007我删除了布局图,它成功了!非常感谢!