我正在 Android 上测试谷歌地图 v2。我按照本教程
当我在手机上运行应用程序时,我看不到地图。我不知道为什么。我不认为,我忘记了什么。我已经配置了所有必要的东西。
这是一个截图:http ://s14.directupload.net/file/d/3130/68zcf2um_png.htm :
logcat 按摩:
01-09 17:25:21.150: D/dalvikvm(18006): Late-enabling CheckJNI
01-09 17:25:21.455: D/dalvikvm(18006): GC_CONCURRENT freed 198K, 3% free 9458K/9735K, paused 2ms+2ms
01-09 17:25:22.075: D/dalvikvm(18006): GC_CONCURRENT freed 268K, 4% free 9635K/9991K, paused 1ms+2ms
01-09 17:25:22.600: D/dalvikvm(18006): GC_CONCURRENT freed 270K, 4% free 9830K/10183K, paused 2ms+2ms
01-09 17:25:22.765: D/dalvikvm(18006): GC_CONCURRENT freed 207K, 3% free 10154K/10439K, paused 2ms+4ms
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 1
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 2
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 3
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 4
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 5
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 6
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 7
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 8
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 9
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 10
01-09 17:25:22.835: D/SensorManager(18006): ====>>>>>Num Sensor: 0
01-09 17:25:22.840: D/SensorManager(18006): registerListener :: handle = 0 name= K3DH Acceleration Sensor delay= 20000 Listener= maps.i.a@416a4570
01-09 17:25:22.845: E/SensorManager(18006): thread start
01-09 17:25:22.845: E/SensorManager(18006): =======>>> Sensor Thread Running <<<========
01-09 17:25:22.960: D/dalvikvm(18006): GC_CONCURRENT freed 259K, 4% free 10322K/10695K, paused 2ms+2ms
01-09 17:25:23.000: D/libEGL(18006): loaded /system/lib/egl/libEGL_mali.so
01-09 17:25:23.050: D/libEGL(18006): loaded /system/lib/egl/libGLESv1_CM_mali.so
01-09 17:25:23.055: D/libEGL(18006): loaded /system/lib/egl/libGLESv2_mali.so
01-09 17:25:23.060: D/(18006): Device driver API match
01-09 17:25:23.060: D/(18006): Device driver API version: 10
01-09 17:25:23.060: D/(18006): User space API version: 10
01-09 17:25:23.060: D/(18006): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Fri Oct 5 16:06:50 KST 2012
01-09 17:25:23.380: D/dalvikvm(18006): GC_FOR_ALLOC freed 202K, 6% free 10336K/10887K, paused 156ms
01-09 17:25:23.405: D/dalvikvm(18006): GC_FOR_ALLOC freed 154K, 6% free 10335K/10887K, paused 19ms
01-09 17:25:23.425: D/dalvikvm(18006): GC_FOR_ALLOC freed 152K, 6% free 10336K/10887K, paused 16ms
01-09 17:25:23.440: D/dalvikvm(18006): GC_FOR_ALLOC freed 152K, 6% free 10336K/10887K, paused 14ms
01-09 17:25:23.460: D/dalvikvm(18006): GC_FOR_ALLOC freed 172K, 6% free 10337K/10887K, paused 14ms
01-09 17:25:23.475: D/dalvikvm(18006): GC_FOR_ALLOC freed 152K, 6% free 10337K/10887K, paused 14ms
01-09 17:25:23.495: D/dalvikvm(18006): GC_FOR_ALLOC freed 152K, 6% free 10338K/10887K, paused 14ms
01-09 17:25:23.510: D/dalvikvm(18006): GC_FOR_ALLOC freed 152K, 6% free 10338K/10887K, paused 14ms
01-09 17:25:23.605: D/CLIPBOARD(18006): Hide Clipboard dialog at Starting input: finished by someone else... !
01-09 17:25:23.725: D/Sensors(18006): Remain listener = Sending .. normal delay 200ms
01-09 17:25:23.725: I/Sensors(18006): sendDelay --- 200000000
01-09 17:25:23.725: D/SensorManager(18006): JNI - sendDelay
01-09 17:25:23.725: I/SensorManager(18006): Set normal delay = true
01-09 17:25:23.725: D/SensorManager(18006): unregisterListener:: disable all sensors for this listener, name = K3DH Acceleration Sensor listener = maps.i.a@416a4570
这是主要活动:
public class MainActivity extends FragmentActivity implements OnMapClickListener {
final int RQS_GooglePlayServices = 1;
GoogleMap myMap;
TextView tvLocInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tvLocInfo = (TextView)findViewById(R.id.textView);
initMap();
}
private void initMap() {
FragmentManager myFragmentManager = getSupportFragmentManager();
SupportMapFragment mySupportMapFragment = (SupportMapFragment)myFragmentManager.findFragmentById(R.id.map);
myMap = mySupportMapFragment.getMap();
myMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
myMap.setMyLocationEnabled(true);
myMap.getUiSettings().setZoomControlsEnabled(true);
myMap.getUiSettings().setCompassEnabled(true);
myMap.getUiSettings().setMyLocationButtonEnabled(true);
myMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
//myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
//myMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
//myMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
myMap.setOnMapClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_legalnotices:
String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(
getApplicationContext());
AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this);
LicenseDialog.setTitle("Legal Notices");
LicenseDialog.setMessage(LicenseInfo);
LicenseDialog.show();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (resultCode == ConnectionResult.SUCCESS){
Toast.makeText(getApplicationContext(),
"isGooglePlayServicesAvailable SUCCESS",
Toast.LENGTH_LONG).show();
}else{
GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices);
}
}
@Override
public void onMapClick(LatLng point) {
tvLocInfo.setText(point.toString());
myMap.animateCamera(CameraUpdateFactory.newLatLng(point));
}
}
main.xml:
<LinearLayout
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:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
和清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlelocatorv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission
android:name="com.example.googlelocatorv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission android:name="your_package_name.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="---myKey---"/>
<activity
android:name="com.example.googlelocatorv2.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>
有人可以帮我弄这个吗?