only Android 5.0 work.
Error by Android 5.0 lower
I have installed all SDK package.
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.allegretti.triestebus" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<permission
android:name="com.allegretti.triestebus.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<!--
The ACCESS_COARSE/FINE_LOCATION 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" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Triestebus" >
<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>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" >
</activity>
</application>
</manifest>
build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.allegretti.triestebus"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:7.0.0'
}
Java class
public class Fragment2 extends Fragment {
MapView mMap;
GoogleMap googleMap;
View rootView;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
rootView = inflater.inflate(R.layout.activity_maps, container, false);
mMap = (MapView) rootView.findViewById(R.id.mapView);
mMap.onCreate(savedInstanceState);
googleMap = mMap.getMap();
// googleMap.getUiSettings().setMyLocationButtonEnabled(false);
// googleMap.setMyLocationEnabled(true);
// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
MapsInitializer.initialize(this.getActivity());
// Updates the location and zoom of the MapView
// CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(45.649526, 13.776818), 13);
// googleMap.animateCamera(cameraUpdate);
/* googleMap.addMarker(new MarkerOptions().position(new LatLng(45.631523, 13.780745)).title("Fermata di Via Svevo").snippet("1-8-29-B"));
googleMap.addMarker(new MarkerOptions().position(new LatLng(45.641204, 13.774329)).title("Fermata di Via Leon Battista Alberti").snippet("29-B"));
googleMap.addMarker(new MarkerOptions().position(new LatLng(45.628215, 13.820757)).title("Fermata di Via Alpi Giulie").snippet("37-48-C"));
googleMap.addMarker(new MarkerOptions().position(new LatLng(45.639983, 13.758070)).title("Fermata di Passeggio Sant'Andrea").snippet("8-9-A"));
googleMap.addMarker(new MarkerOptions().position(new LatLng(45.627767, 13.810545)).title("Fermata di Via Erta Sant'Anna").snippet("34"));
*/
return (rootView);
}
public void onResume() {
super.onResume();
mMap.onResume();
}
@Override
public void onPause() {
super.onPause();
mMap.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
mMap.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMap.onLowMemory();
}
}
EROR
VFY: unable to resolve instance field 16
04-15 16:23:18.943 1791-1791/com.allegretti.triestebus D/dalvikvm﹕ VFY: replacing opcode 0x54 at 0x00b3
04-15 16:23:18.953 1791-1791/com.allegretti.triestebus E/dalvikvm﹕ Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
04-15 16:23:18.953 1791-1791/com.allegretti.triestebus W/dalvikvm﹕ VFY: unable to resolve check-cast 25 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
04-15 16:23:18.953 1791-1791/com.allegretti.triestebus D/dalvikvm﹕ VFY: replacing opcode 0x1f at 0x000e
04-15 16:23:18.963 1791-1791/com.allegretti.triestebus I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzg
04-15 16:23:18.963 1791-1791/com.allegretti.triestebus W/dalvikvm﹕ VFY: unable to resolve virtual method 497: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
04-15 16:23:18.963 1791-1791/com.allegretti.triestebus D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b
04-15 16:23:18.983 1791-1791/com.allegretti.triestebus W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7095000 but found 3136130
04-15 16:23:18.993 1791-1791/com.allegretti.triestebus W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7095000 but found 3136130
04-15 16:23:19.033 1791-1791/com.allegretti.triestebus W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7095000 but found 3136130
04-15 16:23:19.043 1791-1791/com.allegretti.triestebus W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7095000 but found 3136130
04-15 16:23:19.053 1791-1791/com.allegretti.triestebus W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7095000 but found 3136130
Google Maps Api v2 Android Error
Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error Google Maps Api v2 Android Error
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…