I try to run Google Maps with Intellij IDEA 12.
I already tried advices:
and so on. But unfortunately that doesn't work for me.
My configuration:
1) real device htc wildefire s, android 2.3.5
2)
3) AndroidManifest.xml
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.ergeslab.TransportScheduleYaroslavl" android:installLocation="auto" android:versionCode="1" android:versionName="1.0"> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> <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-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <permission android:name="ru.ergeslab.TransportScheduleYaroslavl.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <uses-permission android:name="ru.ergeslab.TransportScheduleYaroslavl.permission.MAPS_RECEIVE"/> <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="16" /> <application android:label="@string/app_name"> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_KEY"/> <uses-library android:name="com.google.android.maps" /> <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> </application> </manifest>
4) MainActivity:
<pre>
package ru.ergeslab.TransportScheduleYaroslavl;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
5) main.xml
:
<?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" />
6) IDE project settings:
Full Android logcat:
04-02 21:27:07.718: ERROR/AndroidRuntime(24277): FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) at android.view.LayoutInflater.inflate(LayoutInflater.java:386) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at android.view.LayoutInflater.inflate(LayoutInflater.java:276) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250) at android.app.Activity.setContentView(Activity.java:1712) at ru.ergeslab.TransportScheduleYaroslavl.MainActivity.onCreate(MainActivity.java:13) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851) at android.app.ActivityThread.access$1500(ActivityThread.java:132) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:4277) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method)
Any help is greatly appreciated.
I finally ran my application!
I didn't edit manifest, layout and activity, just updated project settings:
I hope this will help someone.
1. Remove this permission from the manifest file:
<uses-library android:name="com.google.android.maps" />
it's part of Google Maps API V1 and not needed in Google Maps API V2.
2. Move the meta-data part to be right before the closing application tag:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY_KEY"/>
</application>
3. Regenerate a new key and register it via the Google API Console and make all the process again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With