Note that there are some explanatory texts on larger screens.

plurals
  1. PORuntime Error in MapsDemo Activity
    primarykey
    data
    text
    <p>I'm using <a href="https://developers.google.com/maps/documentation/android/start#adding_the_api_key_to_your_application" rel="nofollow">this tutorial from Google for MapsActivity</a> but for some reason I have not been getting the required output, the application crashes.</p> <p>Here is the code I'm using:</p> <ol> <li><p>Manifest.xml</p> <p> </p> <pre><code>&lt;uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="com.ajinkya.samplemapsdemo.permission.MAPS_RECEIVE" /&gt; &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt; &lt;permission android:name="com.ajinkya.samplemapsdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature" /&gt; &lt;uses-feature android:glEsVersion="0x00020000" android:required="true" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.ajinkya.samplemapsdemo.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="blahblahblahkey" /&gt; &lt;/application&gt; </code></pre> <p></p></li> <li><p>main.xml</p> <p></p> <pre><code>&lt;fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.MapFragment"/&gt; </code></pre> <p></p></li> <li><p>MainActivity.java</p> <pre><code> package com.ajinkya.samplemapsdemo; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; }} </code></pre></li> </ol> <p>According to Google, a map should be displayed, which is not happening. It gives me the message:</p> <pre><code>Unfortunately, samplemapsdemo has stopped. </code></pre> <p>Here is the log:</p> <pre><code>08-01 18:30:21.671: D/ActivityThread(10657): setTargetHeapUtilization:0.25 08-01 18:30:21.671: D/ActivityThread(10657): setTargetHeapIdealFree:8388608 08-01 18:30:21.671: D/ActivityThread(10657): setTargetHeapConcurrentStart:2097152 08-01 18:30:21.741: W/dalvikvm(10657): threadid=1: thread exiting with uncaught exception (group=0x40a9f390) 08-01 18:31:36.581: D/ActivityThread(10705): setTargetHeapUtilization:0.25 08-01 18:31:36.581: D/ActivityThread(10705): setTargetHeapIdealFree:8388608 08-01 18:31:36.591: D/ActivityThread(10705): setTargetHeapConcurrentStart:2097152 08-01 18:31:36.801: W/dalvikvm(10705): threadid=1: thread exiting with uncaught exception (group=0x40a9f390) 08-01 18:31:36.831: E/AndroidRuntime(10705): FATAL EXCEPTION: main 08-01 18:31:36.831: E/AndroidRuntime(10705): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ajinkya.samplemapsdemo/com.ajinkya.samplemapsdemo.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1959) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1984) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.ActivityThread.access$600(ActivityThread.java:126) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1150) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.os.Handler.dispatchMessage(Handler.java:99) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.os.Looper.loop(Looper.java:137) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.ActivityThread.main(ActivityThread.java:4456) 08-01 18:31:36.831: E/AndroidRuntime(10705): at java.lang.reflect.Method.invokeNative(Native Method) 08-01 18:31:36.831: E/AndroidRuntime(10705): at java.lang.reflect.Method.invoke(Method.java:511) 08-01 18:31:36.831: E/AndroidRuntime(10705): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) 08-01 18:31:36.831: E/AndroidRuntime(10705): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554) 08-01 18:31:36.831: E/AndroidRuntime(10705): at dalvik.system.NativeStart.main(Native Method) 08-01 18:31:36.831: E/AndroidRuntime(10705): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 08-01 18:31:36.831: E/AndroidRuntime(10705): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Activity.setContentView(Activity.java:1835) 08-01 18:31:36.831: E/AndroidRuntime(10705): at com.ajinkya.samplemapsdemo.MainActivity.onCreate(MainActivity.java:15) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Activity.performCreate(Activity.java:4465) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1923) 08-01 18:31:36.831: E/AndroidRuntime(10705): ... 11 more 08-01 18:31:36.831: E/AndroidRuntime(10705): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Fragment.instantiate(Fragment.java:581) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Fragment.instantiate(Fragment.java:549) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Activity.onCreateView(Activity.java:4235) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673) 08-01 18:31:36.831: E/AndroidRuntime(10705): ... 21 more 08-01 18:31:36.831: E/AndroidRuntime(10705): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment 08-01 18:31:36.831: E/AndroidRuntime(10705): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 08-01 18:31:36.831: E/AndroidRuntime(10705): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 08-01 18:31:36.831: E/AndroidRuntime(10705): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 08-01 18:31:36.831: E/AndroidRuntime(10705): at android.app.Fragment.instantiate(Fragment.java:571) 08-01 18:31:36.831: E/AndroidRuntime(10705): ... 24 more </code></pre> <p>I believe that this line may be the root cause of all of the problems:</p> <pre><code>08-01 18:31:36.831: E/AndroidRuntime(10705): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public </code></pre> <p>Any help would be appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload