您好 我已经阅读了很多关于如何使地图与爱人而不是11sdk一起工作的回复,但我做了所有事情,但仍然无法使其发挥作用。我的minsdk设置为8.我总是得到这样的错误:
清单合并失败:uses-sdk:minSdkVersion 8不能小于com.google.android.gms库中声明的版本9:play-services:6.1.71`
我无法将我的min sdk更改为9或11,因为我绝望地需要它为8.我已经尝试改为supportmapfragment等等。这是我的代码: fragment_maps.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
maps.java
package com.miesto.meniu;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.*;
import android.os.Build;
import com.google.android.gms.maps.SupportMapFragment;
import android.widget.Toast;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.text.SimpleDateFormat;
public class maps extends FragmentActivity {
Fragment fragment = getSupportFragmentManager().findFragmentById(
R.id.mapView);
SupportMapFragment mapFragment = (SupportMapFragment) fragment;
GoogleMap mMap = mapFragment.getMap();
@Override
protected void onCreate(Bundle savedInstanceState) {
createMapView();
addMarker();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
GoogleMap googleMap;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.maps, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_maps, container, false);
return rootView;
}
}
/**
* THIS WONT WORK SO I JUST COMMENTED IT BUT LEFT IT IF ILL NEED IT LATER
*/
private void createMapView(){
/**
* Catch the null pointer exception that
* may be thrown when initialising the map
try {
if(null == googleMap){
HERE I GET ERROR THAT getfragmentmanager and findfragmentbyid NEED minsdk 11
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.mapView)).getMap();
if(null == googleMap) {
Toast.makeText(getApplicationContext(),
"Klaida rodant zemelapi", Toast.LENGTH_SHORT).show();
}
}
} catch (NullPointerException exception){
Log.e("miesto.meniu", exception.toString());
}
*/
}
/** -------------------------------
*
*/
/**
* Adds a marker to the map
*/
private void addMarker(){
/** Make sure that the map has been initialised **/
if(null != googleMap){
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Marker")
.draggable(true)
);
}
}
}
非常感谢任何帮助
答案 0 :(得分:0)
google-play-services_lib显示更改android:minSdkVersion 8
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms"
android:versionCode="6171000"
android:versionName="6.1.71-000" >
<uses-sdk android:minSdkVersion="9" />
<application />