android - INSTALL_FAILED_OLDER_SDK when installing apk -
i'm trying test project in phone android 2.3.6 , error message: install_failed_older_sdk
the app drawing route between 2 points;
there code: xml file:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".mainactivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.supportmapfragment" />
the java files:
package com.example.getroutexy2; import java.util.arraylist; import java.util.list; import org.w3c.dom.document; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.markeroptions; import com.google.android.gms.maps.model.polylineoptions; import com.google.android.maps.geopoint; import com.google.android.maps.overlay; import android.app.progressdialog; import android.graphics.color; import android.graphics.drawable.drawable; import android.location.location; import android.location.locationmanager; import android.os.asynctask; import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.view.menu; public class mainactivity extends fragmentactivity { list<overlay> mapoverlays; geopoint point1, point2; locationmanager locmanager; drawable drawable; document document; gmapv2getroutedirection v2getroutedirection; latlng fromposition; latlng toposition; googlemap mgooglemap; markeroptions markeroptions; location location ; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); v2getroutedirection = new gmapv2getroutedirection(); supportmapfragment supportmapfragment = (supportmapfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.map); mgooglemap = supportmapfragment.getmap(); // enabling mylocation in google map mgooglemap.setmylocationenabled(true); mgooglemap.getuisettings().setzoomcontrolsenabled(true); mgooglemap.getuisettings().setcompassenabled(true); mgooglemap.getuisettings().setmylocationbuttonenabled(true); mgooglemap.getuisettings().setallgesturesenabled(true); mgooglemap.settrafficenabled(true); mgooglemap.animatecamera(cameraupdatefactory.zoomto(12)); markeroptions = new markeroptions(); fromposition = new latlng(11.663837, 78.147297); toposition = new latlng(11.723512, 78.466287); getroutetask getroute = new getroutetask(); getroute.execute(); } private class getroutetask extends asynctask<string, void, string> { private progressdialog dialog; string response = ""; @override protected void onpreexecute() { dialog = new progressdialog(mainactivity.this); dialog.setmessage("loading route..."); dialog.show(); } @override protected string doinbackground(string... urls) { //get route values document = v2getroutedirection.getdocument(fromposition, toposition, gmapv2getroutedirection.mode_driving); response = "success"; return response; } @override protected void onpostexecute(string result) { mgooglemap.clear(); if(response.equalsignorecase("success")){ arraylist<latlng> directionpoint = v2getroutedirection.getdirection(document); polylineoptions rectline = new polylineoptions().width(10).color( color.red); (int = 0; < directionpoint.size(); i++) { rectline.add(directionpoint.get(i)); } // adding route on map mgooglemap.addpolyline(rectline); markeroptions.position(toposition); markeroptions.draggable(true); mgooglemap.addmarker(markeroptions); } dialog.dismiss(); } } @override protected void onstop() { super.onstop(); finish(); } }
and
package com.example.getroutexy2; import java.io.inputstream; import java.util.arraylist; import javax.xml.parsers.documentbuilder; import javax.xml.parsers.documentbuilderfactory; import org.apache.http.httpresponse; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.protocol.basichttpcontext; import org.apache.http.protocol.httpcontext; import org.w3c.dom.document; import org.w3c.dom.node; import org.w3c.dom.nodelist; import android.util.log; import com.google.android.gms.maps.model.latlng; public class gmapv2getroutedirection { public final static string mode_driving = "driving"; public final static string mode_walking = "walking"; public gmapv2getroutedirection() { } public document getdocument(latlng start, latlng end, string mode) { string url = "http://maps.googleapis.com/maps/api/directions/xml?" + "origin=" + start.latitude + "," + start.longitude + "&destination=" + end.latitude + "," + end.longitude + "&sensor=false&units=metric&mode=driving"; try { httpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httppost httppost = new httppost(url); httpresponse response = httpclient.execute(httppost, localcontext); inputstream in = response.getentity().getcontent(); documentbuilder builder = documentbuilderfactory.newinstance().newdocumentbuilder(); document doc = builder.parse(in); return doc; } catch (exception e) { e.printstacktrace(); } return null; } public string getdurationtext (document doc) { nodelist nl1 = doc.getelementsbytagname("duration"); node node1 = nl1.item(0); nodelist nl2 = node1.getchildnodes(); node node2 = nl2.item(getnodeindex(nl2, "text")); log.i("durationtext", node2.gettextcontent()); return node2.gettextcontent(); } public int getdurationvalue (document doc) { nodelist nl1 = doc.getelementsbytagname("duration"); node node1 = nl1.item(0); nodelist nl2 = node1.getchildnodes(); node node2 = nl2.item(getnodeindex(nl2, "value")); log.i("durationvalue", node2.gettextcontent()); return integer.parseint(node2.gettextcontent()); } public string getdistancetext (document doc) { nodelist nl1 = doc.getelementsbytagname("distance"); node node1 = nl1.item(0); nodelist nl2 = node1.getchildnodes(); node node2 = nl2.item(getnodeindex(nl2, "text")); log.i("distancetext", node2.gettextcontent()); return node2.gettextcontent(); } public int getdistancevalue (document doc) { nodelist nl1 = doc.getelementsbytagname("distance"); node node1 = nl1.item(0); nodelist nl2 = node1.getchildnodes(); node node2 = nl2.item(getnodeindex(nl2, "value")); log.i("distancevalue", node2.gettextcontent()); return integer.parseint(node2.gettextcontent()); } public string getstartaddress (document doc) { nodelist nl1 = doc.getelementsbytagname("start_address"); node node1 = nl1.item(0); log.i("startaddress", node1.gettextcontent()); return node1.gettextcontent(); } public string getendaddress (document doc) { nodelist nl1 = doc.getelementsbytagname("end_address"); node node1 = nl1.item(0); log.i("startaddress", node1.gettextcontent()); return node1.gettextcontent(); } public string getcopyrights (document doc) { nodelist nl1 = doc.getelementsbytagname("copyrights"); node node1 = nl1.item(0); log.i("copyrights", node1.gettextcontent()); return node1.gettextcontent(); } public arraylist<latlng> getdirection (document doc) { nodelist nl1, nl2, nl3; arraylist<latlng> listgeopoints = new arraylist<latlng>(); nl1 = doc.getelementsbytagname("step"); if (nl1.getlength() > 0) { (int = 0; < nl1.getlength(); i++) { node node1 = nl1.item(i); nl2 = node1.getchildnodes(); node locationnode = nl2.item(getnodeindex(nl2, "start_location")); nl3 = locationnode.getchildnodes(); node latnode = nl3.item(getnodeindex(nl3, "lat")); double lat = double.parsedouble(latnode.gettextcontent()); node lngnode = nl3.item(getnodeindex(nl3, "lng")); double lng = double.parsedouble(lngnode.gettextcontent()); listgeopoints.add(new latlng(lat, lng)); locationnode = nl2.item(getnodeindex(nl2, "polyline")); nl3 = locationnode.getchildnodes(); latnode = nl3.item(getnodeindex(nl3, "points")); arraylist<latlng> arr = decodepoly(latnode.gettextcontent()); for(int j = 0 ; j < arr.size() ; j++) { listgeopoints.add(new latlng(arr.get(j).latitude, arr.get(j).longitude)); } locationnode = nl2.item(getnodeindex(nl2, "end_location")); nl3 = locationnode.getchildnodes(); latnode = nl3.item(getnodeindex(nl3, "lat")); lat = double.parsedouble(latnode.gettextcontent()); lngnode = nl3.item(getnodeindex(nl3, "lng")); lng = double.parsedouble(lngnode.gettextcontent()); listgeopoints.add(new latlng(lat, lng)); } } return listgeopoints; } private int getnodeindex(nodelist nl, string nodename) { for(int = 0 ; < nl.getlength() ; i++) { if(nl.item(i).getnodename().equals(nodename)) return i; } return -1; } private arraylist<latlng> decodepoly(string encoded) { arraylist<latlng> poly = new arraylist<latlng>(); int index = 0, len = encoded.length(); int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; { b = encoded.charat(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lat += dlat; shift = 0; result = 0; { b = encoded.charat(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; latlng position = new latlng((double) lat / 1e5, (double) lng / 1e5); poly.add(position); } return poly; } }
finally manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.getroutexy2" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="7" android:targetsdkversion="17" /> <permission android:name="com.example.getroutexy2.permission.maps_receive" android:protectionlevel="signature" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-permission android:name="com.example.getroutexy2.permission.maps_receive" /> <uses-permission android:name="android.permission.internet" /> <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_network_state" /> <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" > <activity android:name="com.example.getroutexy2.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.maps.v2.api_key" android:value="aizasyckdoz..............." /> </application>
thanks, key i'm sure it's one
either:
your device not running android 2.3.6, or
your application not have manifest, or
you misinterpreting something, or
your device or app strange
install_failed_older_sdk
should occur if api level of device below android:minsdkversion
. in case, android:minsdkversion
7
, android 2.1. hence, should not getting error.
Comments
Post a Comment