有在安卓上搞成功过google地图显示的请进!

收藏快乐 2016-10-12 03:36:19
需要在app中加入一个地图页面,必须要用google地图,研究了一周都没搞出来,在此想请问各位大侠,应该怎么?难道安卓上不能跑google地图?以下是我的代码:用的是Google APIs 4.4.2

package com.example.googlemapview;

import android.os.Bundle;
import com.google.android.maps.*;

public class MainActivity extends MapActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true); //设置mapView显示用于缩放的工具条 }
}

@Override
protected boolean isRouteDisplayed() {
return false;
}
}

Mainfest是这样的
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemapview"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="24" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<uses-library android:name="com.google.android.maps" />

<activity
android:name=".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>
</application>

</manifest>

布局文件是这样的
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.googlemapview.MainActivity" >

<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> -->

<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="AIzaSyDCYMcdgHP1jPEp9crnuLkjEWcphi_1l2E"
/>

</RelativeLayout>

现在的问题是编译什么的都没问题,但是在运行的时候,就直接挂掉了.public class MainActivity extends MapActivity 无法生成这个类,也就是MapActivity 无效,那应该就是在运行的时候com.google.android.maps根本没有加载进来,这是什么原因呢?我折腾了一周,加之是新手,请各位有成功开发过google地图的大神们帮忙解答,多谢!
...全文
197 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧