Android google map v2 maven -
i creating android application using google maps , maven. put in pom.xml 2 dependencies
<dependency> <groupid>com.google.android.gms</groupid> <artifactid>google-play-services</artifactid> <version>4</version> <type>apklib</type> </dependency> <dependency> <groupid>com.google.android.gms</groupid> <artifactid>google-play-services</artifactid> <version>4</version> <type>jar</type> </dependency>
the apklib , jar appears in maven repository.(m2\repository)
main_map.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainlay" android:layout_width="match_parent" android:layout_height="match_parent" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.supportmapfragment"/> </relativelayout>
i put permissions , metadatada api key in androidmanifest.
<permission android:name="com.map.example.permission.maps_receive" android:protectionlevel="signature" /> <uses-permission android:name="com.map.example.permission.maps_receive" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permissionndroid:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_fine_location"/> <uses-feature android:glesversion="0x00020000" android:required="true" /> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="aizasydrdsq0vayysrs__0a8yb2yr333w_z1uao" />
mainactivity
import android.os.bundle; import android.support.v4.app.fragmentactivity; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.supportmapfragment; public class mainactivity extends fragmentactivity { private googlemap map; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main_map.xml); map = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)) .getmap(); } }
i got exception
04-18 10:32:37.939: e/androidruntime(21550): fatal exception: main 04-18 10:32:37.939: e/androidruntime(21550): java.lang.noclassdeffounderror: com.google.android.gms.r$styleable 04-18 10:32:37.939: e/androidruntime(21550): @ com.google.android.gms.maps.googlemapoptions.createfromattributes(unknown source) 04-18 10:32:37.939: e/androidruntime(21550): @ com.google.android.gms.maps.supportmapfragment.oninflate(unknown source) 04-18 10:32:37.939: e/androidruntime(21550): @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:269) 04-18 10:32:37.939: e/androidruntime(21550): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:563) 04-18 10:32:37.939: e/androidruntime(21550): @ android.view.layoutinflater.rinflate(layoutinflater.java:623) 04-18 10:32:37.939: e/androidruntime(21550): @ android.view.layoutinflater.inflate(layoutinflater.java:408) 04-18 10:32:37.939: e/androidruntime(21550): @ android.view.layoutinflater.inflate(layoutinflater.java:320) 04-18 10:32:37.939: e/androidruntime(21550): @ android.view.layoutinflater.inflate(layoutinflater.java:276) 04-18 10:32:37.939: e/androidruntime(21550): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:207) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.activity.setcontentview(activity.java:1657) 04-18 10:32:37.939: e/androidruntime(21550): @ com.codespring.androidspeed.ui.newui.mainpager.oncreate(mainpager.java:62) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.activitythread.performlaunchactivity(activitythread.java:1615) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.activitythread.access$1500(activitythread.java:117) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.activitythread$h.handlemessage(activitythread.java:931) 04-18 10:32:37.939: e/androidruntime(21550): @ android.os.handler.dispatchmessage(handler.java:99) 04-18 10:32:37.939: e/androidruntime(21550): @ android.os.looper.loop(looper.java:123) 04-18 10:32:37.939: e/androidruntime(21550): @ android.app.activitythread.main(activitythread.java:3729) 04-18 10:32:37.939: e/androidruntime(21550): @ java.lang.reflect.method.invokenative(native method) 04-18 10:32:37.939: e/androidruntime(21550): @ java.lang.reflect.method.invoke(method.java:507) 04-18 10:32:37.939: e/androidruntime(21550): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:874) 04-18 10:32:37.939: e/androidruntime(21550): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:632) 04-18 10:32:37.939: e/androidruntime(21550): @ dalvik.system.nativestart.main(native method)
anyone can me this?
i have maven build set in project.
here relevant pom files:
http://code.google.com/p/android-maps-extensions/source/browse/android-maps-extensions/pom.xml
http://code.google.com/p/android-maps-extensions/source/browse/android-maps-extensions-demo/pom.xml
this not clear google maps android api v2, lib based on it.
how starting app? should doing mvn android:deploy android:run
. find running maven eclipse buggy (but maybe i'm doing wrong).
Comments
Post a Comment