Java 谷歌地图只显示棕色屏幕和缩放
我想在我的android应用程序中显示google地图应用程序: 我完成了android developer中提到的步骤: 但是,在我的应用程序中,它会显示一个带有缩放(加号和减号按钮)的棕色屏幕,而没有地图本身(它不会显示任何错误) 我创建了这个xml文件:Java 谷歌地图只显示棕色屏幕和缩放,java,android,Java,Android,我想在我的android应用程序中显示google地图应用程序: 我完成了android developer中提到的步骤: 但是,在我的应用程序中,它会显示一个带有缩放(加号和减号按钮)的棕色屏幕,而没有地图本身(它不会显示任何错误) 我创建了这个xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andro
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/itemImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/logo" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="400dp"
android:layout_marginTop="10dp"
android:layout_weight="66496.79"
android:orientation="horizontal" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
</RelativeLayout>
</LinearLayout>
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sal"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="1"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<permission
android:name="com.example.sal.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.example.sal.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name=".FriendPickerApplication">
<activity
android:name="com.example.sal.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Entry for RegisterActivity.class -->
<activity android:name=".RegisterActivity"
android:label="Register New Account"></activity>
<meta-data android:value="@string/app_id" android:name="com.facebook.sdk.ApplicationId"/>
<activity android:label="@string/app_name" android:name="com.facebook.LoginActivity"></activity>
<activity android:name=".ProfileActivity" android:label="Profile page"></activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="zzzz"/>
<activity android:name="SaleMapActivity"></activity>
<activity android:name="GroupMapActivity"></activity>
<activity android:name="DeliverMapActivity"></activity>
<activity android:name="PickFriendsActivity"></activity>
<activity android:name="TabMainActivity"></activity>
<activity android:name="itemSaleActivity"></activity>
<activity android:name="FreindsActivity"></activity>
<activity android:name="ExitActivity"></activity>
<activity android:name="OneTimeDetailesScreen"></activity>
<activity android:name="UpdateMapActivity"></activity>
<activity android:name="DashBoardActivity"></activity>
</application>
</manifest
更改此选项:
<permission
android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
到
我不确定这是否会有帮助,但这是我在上一个项目中使用的布局代码
(注意不同的片段类)
非常感谢,我会尝试一下,还有,我需要更改此行吗?:@不,你不需要。请确保将MAPS_RECEIVE的包名更改为您自己的包名,显然@Corey并不是要将包名更改为example.sal
,而是您自己的包名。这一行似乎也有点奇怪。尝试将其更改为应用程序的程序包名称?是不是com.vogella.android.locationapi.maps
?您好,我把它改成了我的软件包名称,但是还是一样的问题…您检查过您的设备的日期/时间了吗?对吗?我知道这听起来很奇怪,但我以前遇到过这个问题是的,设备的时间和日期是正确的。我可以知道你的软件包名吗?你能将更新的清单文件发布到问题中吗?谢谢
<permission
android:name="com.example.sal.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<fragment
android:id="@+id/map_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.SupportMapFragment"
map:mapType="normal"
map:cameraTargetLat="@string/default_map_lat"
map:cameraTargetLng="@string/default_map_lng"
map:cameraZoom="8">
</fragment>