I have been trying to integrate Google Maps into Android App.I am Android noob and sort of confused on how to do this the right way.My first issue was that Using API 4.0 based emulator I accomplished the setup outlined here successfully, but when running it showed no map - only map controls.Then I found that it's impossible to debug Google Maps V2 on emulator.So I tried to run it on device.The device is HTC with Android 2.3.5 .The app had been constantly crashing once I uploaded it for test to the phone.Then here I found the guy using :
class="com.google.android.gms.maps.SupportMapFragment"
in the node ,rather than this:
android:name="com.google.android.gms.maps.MapFragment" //from Google maps setup webpage
Can anyone explain why?I Also found that I had to replace my activity super class from Activity to FragmentActivity which is also not covered in Google's docs.
Another thing:when selecting the device to debug on I see a warning icon for my HTC phone (see below)
What does the warning mean?
And here is my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.example.helloworld.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.helloworld.permission.MAPS_RECEIVE"/>
<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"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
<activity
android:name="com.example.helloworld.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>
Do all those Google official docs target only the latest APIs?
Here is the error stack trace ( if using setup as in Google Maps tutorial )
12-02 19:27:55.345: E/AndroidRuntime(11590): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
dalvik.system.NativeStart.main(Native Method) 12-02 19:27:55.345:
E/AndroidRuntime(11590): Caused by: android.view.InflateException:
Binary XML file line #3: Error inflating class fragment 12-02
19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.inflate(LayoutInflater.java:386) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.inflate(LayoutInflater.java:276) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
android.app.Activity.setContentView(Activity.java:1742) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
com.example.helloworld.MainActivity.onCreate(MainActivity.java:15)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
12-02 19:27:55.345: E/AndroidRuntime(11590): ... 11 more 12-02
19:27:55.345: E/AndroidRuntime(11590): Caused by:
java.lang.ClassNotFoundException: android.view.fragment in loader
dalvik.system.PathClassLoader[/data/app/com.example.helloworld-2.apk]
12-02 19:27:55.345: E/AndroidRuntime(11590): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
java.lang.ClassLoader.loadClass(ClassLoader.java:551) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
java.lang.ClassLoader.loadClass(ClassLoader.java:511) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.createView(LayoutInflater.java:471) 12-02
19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
12-02 19:27:55.345: E/AndroidRuntime(11590): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
12-02 19:27:55.345: E/AndroidRuntime(11590): ... 19 more
Related
I am trying to build an Android application which uses Google Maps. The application is immediately crashing. I have removed JAR files from the buildpath, and cleaned my project, but to no avail. Please help.
04-20 18:42:14.452: E/AndroidRuntime(20594): FATAL EXCEPTION: main
04-20 18:42:14.452: E/AndroidRuntime(20594): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{info.androidhive.tabsswipe/info.androidhive.tabsswipe.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "info.androidhive.tabsswipe.MainActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/info.androidhive.tabsswipe-5.apk
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2232)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2362)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.ActivityThread.access$700(ActivityThread.java:168)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1329)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.os.Looper.loop(Looper.java:176)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.ActivityThread.main(ActivityThread.java:5493)
04-20 18:42:14.452: E/AndroidRuntime(20594): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 18:42:14.452: E/AndroidRuntime(20594): at java.lang.reflect.Method.invoke(Method.java:525)
04-20 18:42:14.452: E/AndroidRuntime(20594): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
04-20 18:42:14.452: E/AndroidRuntime(20594): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
04-20 18:42:14.452: E/AndroidRuntime(20594): at dalvik.system.NativeStart.main(Native Method)
04-20 18:42:14.452: E/AndroidRuntime(20594): Caused by: java.lang.ClassNotFoundException: Didn't find class "info.androidhive.tabsswipe.MainActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/info.androidhive.tabsswipe-5.apk
04-20 18:42:14.452: E/AndroidRuntime(20594): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
04-20 18:42:14.452: E/AndroidRuntime(20594): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-20 18:42:14.452: E/AndroidRuntime(20594): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
04-20 18:42:14.452: E/AndroidRuntime(20594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2223)
04-20 18:42:14.452: E/AndroidRuntime(20594): ... 11 more
My AndroidManifest.xml is given below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.tabsswipe"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<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=".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:value="#string/app_id" android:name="com.facebook.sdk.ApplicationId"/>
<activity android:name="com.facebook.LoginActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar">
</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="AIzaSyCoNGG7fbUlRzMO74WvSlCai4x3LPzmANs"/>
<uses-library android:name="com.google.android.maps"/>
</application>
</manifest>
Goto:
Project -> Properties -> Java Build Path -> Order & Export and check if Android Private Libraries are already checked and any other library you have imported.
and then
Clean
Build
Run
I'm new in Android development. I want to add Google maps to my application. I have done lots of searches but still the same problem arises when I run the application "Unfortunately , application has stopped"
So this is my java class
package com.example.hellomap;
import com.google.android.maps.MapView;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_main);
MapView map =(MapView) findViewById(R.id.map);
}
}
the xml file :
<?xml version="1.0" encoding="utf-8"?>
<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"/>
and the Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellomap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name="com.example.hellomap.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="AIzaSyCKSp9pb7g8Wkga2SgeoT_MSe0JG59DkSU" />
</application>
</manifest>
The LogCat shows:
04-03 13:45:42.574: E/AndroidRuntime(1164): FATAL EXCEPTION: main
04-03 13:45:42.574: E/AndroidRuntime(1164): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hellomap/com.example.hellomap.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.os.Looper.loop(Looper.java:137)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-03 13:45:42.574: E/AndroidRuntime(1164): at dalvik.system.NativeStart.main(Native Method)
04-03 13:45:42.574: E/AndroidRuntime(1164): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Activity.setContentView(Activity.java:1867)
04-03 13:45:42.574: E/AndroidRuntime(1164): at com.example.hellomap.MainActivity.onCreate(MainActivity.java:23)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Activity.performCreate(Activity.java:5008)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-03 13:45:42.574: E/AndroidRuntime(1164): ... 11 more
04-03 13:45:42.574: E/AndroidRuntime(1164): 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
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Fragment.instantiate(Fragment.java:584)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Fragment.instantiate(Fragment.java:552)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Activity.onCreateView(Activity.java:4656)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-03 13:45:42.574: E/AndroidRuntime(1164): ... 20 more
04-03 13:45:42.574: E/AndroidRuntime(1164): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
04-03 13:45:42.574: E/AndroidRuntime(1164): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-03 13:45:42.574: E/AndroidRuntime(1164): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-03 13:45:42.574: E/AndroidRuntime(1164): at android.app.Fragment.instantiate(Fragment.java:574)
04-03 13:45:42.574: E/AndroidRuntime(1164): ... 23 more
04-03 13:50:42.626: I/Process(1164): Sending signal. PID: 1164 SIG: 9
Thanks for help :)
EXCEPTION :- ClassNotFoundException
please check GooglePlayService Library Project First.
Second Thing You Can Not Type Cast Fragment To Map View, please read this
Update:-
Follow The Step:-
1)Create New Project
2)Import GooglePlayService Library project into Your Workspace.
3)assign Google play Service library project as library project to your project
4)now add Map Fragment/Supported Map Fragment into your activity layout file
5)make sure this class found
how to check==>press control Key from keyboard and click on class name id you found class then it's okay other wise fix it first.
i prefer to use Supported Fragment.
6)define all permission as describe in link i posted previously.
6)now its time to generate api key for map ,follow the step from given link.
Thanks i hope its help
I am following Google Maps Android API v2 setup guide and I did everything in the guide but the things don't seem to work and I get "The application mapdemo (process com.example.mapdemo) has stopped unexpectedly. Please try again". I have wasted 1 whole day and still cannot find a solution. :(
My Manifest file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<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" />
<!--
The following two 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" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mapdemo.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="AIzaSyC253yRJk8FVwFbuGiMOTn5Cp7C2vdTMx4" />
</application>
</manifest>
activity_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.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
MainActivity.java
package com.example.mapdemo;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
LogCat output is:
06-27 10:58:09.263: D/AndroidRuntime(18097): Shutting down VM
06-27 10:58:09.263: W/dalvikvm(18097): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
06-27 10:58:09.273: E/AndroidRuntime(18097): FATAL EXCEPTION: main
06-27 10:58:09.273: E/AndroidRuntime(18097): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapdemo/com.example.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.os.Looper.loop(Looper.java:143)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.main(ActivityThread.java:4196)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.reflect.Method.invoke(Method.java:507)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-27 10:58:09.273: E/AndroidRuntime(18097): at dalvik.system.NativeStart.main(Native Method)
06-27 10:58:09.273: E/AndroidRuntime(18097): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:224)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.Activity.setContentView(Activity.java:1702)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.example.mapdemo.MainActivity.onCreate(MainActivity.java:11)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
06-27 10:58:09.273: E/AndroidRuntime(18097): ... 11 more
06-27 10:58:09.273: E/AndroidRuntime(18097): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.mapdemo-2.apk]
06-27 10:58:09.273: E/AndroidRuntime(18097): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
06-27 10:58:09.273: E/AndroidRuntime(18097): ... 19 more
The error is so frustrating. Any help will be greatly appreciated. Thanks
The error says that the class is not found. There seems to be an issue with the way you added google-play-services project(support libray), if at all you did. Checkout:
Error java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in Google Map V2
Unable instantiate android.gms.maps.MapFragment
java.lang.noclassdeffounderror: com.google.android.gms.R$styleable nothing helped me
They talk about similar issue. Hope it helps.
I'm trying to use OSMdroid for a project, and i'm utterly unable to make the simplest code work.
Well, a few days ago i was able to display maps and so on, and now i can't even instantiate a MapView.
I reduced the code to its sipmlest form.
I work with eclipse. I downloaded osmdroid-android-3.0.5.jar and slf4j-android-1.5.8.jar, and i included them in the project by adding lines to the classpath file
<classpathentry kind="lib" path="lib/osmdroid-android-3.0.5.jar"/>
<classpathentry kind="lib" path="lib/slf4j-android-1.5.8.jar"/>
Or by right clicking on them then Build Path-> Add to build path (both gave the same result, anyway)
Then i typed this code:
import android.app.Activity;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.os.Bundle;
public class TestMapActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mv=new MapView(this,256);
}
}
And i get a bug when running it on the emulator:
04-17 09:10:31.181: E/AndroidRuntime(595): FATAL EXCEPTION: main
04-17 09:10:31.181: E/AndroidRuntime(595): java.lang.NoClassDefFoundError: org.osmdroid.views.MapView
04-17 09:10:31.181: E/AndroidRuntime(595): at testmap.sagem.TestMapActivity.onCreate(TestMapActivity.java:17)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.Activity.performCreate(Activity.java:4465)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.os.Looper.loop(Looper.java:137)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-17 09:10:31.181: E/AndroidRuntime(595): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 09:10:31.181: E/AndroidRuntime(595): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 09:10:31.181: E/AndroidRuntime(595): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-17 09:10:31.181: E/AndroidRuntime(595): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-17 09:10:31.181: E/AndroidRuntime(595): at dalvik.system.NativeStart.main(Native Method)
When i comment out the "MapView mv=new MapView(this,256);" it works, so i don't understand why the mapview can't be instantiated.
Any idea on this?
Thank you for your attention.
EDIT:
The AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testmap.sagem"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".TestMapActivity"
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>
The main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
Change Folder name "lib" to "libs" and put all jar files in that folder and Charge path of jar
files to "libs" folder. I am not sure but I think it will work.
Try to use the 3.0.7 and clean the project.
Let me know.
http://code.google.com/p/osmdroid/downloads/list
I've been trying to get started with Android programming for a while now. I'm mainly a .NET developer with no Java experience for 8 years (university).
I can compile and run samples no problem but the moment I try and rename my package/class it fails. I believe I've updated the manifest and triple checked it (Copied and pasted name, selected it with Eclipse) yet it always fails with a java.lang.ClassNotFoundException:
12-02 09:12:21.088: ERROR/AndroidRuntime(233): Uncaught handler: thread main exiting due to uncaught exception
12-02 09:12:21.178: ERROR/AndroidRuntime(233): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.anddev.cheesemp.helloandworld/org.anddev.cheesemp.helloandworld.HelloAndEngine}: java.lang.ClassNotFoundException: org.anddev.cheesemp.helloandworld.HelloAndEngine in loader dalvik.system.PathClassLoader#43d0c0d0
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.os.Handler.dispatchMessage(Handler.java:99)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.os.Looper.loop(Looper.java:123)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.main(ActivityThread.java:4363)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.reflect.Method.invoke(Method.java:521)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at dalvik.system.NativeStart.main(Native Method)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): Caused by: java.lang.ClassNotFoundException: org.anddev.cheesemp.helloandworld.HelloAndEngine in loader dalvik.system.PathClassLoader#43d0c0d0
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): ... 11 more
Manifest is here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="org.anddev.cheesemp.helloandworld">
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="org.anddev.cheesemp.helloandworld.HelloAndEngine">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" \>
</manifest>
Class definition is here:
package org.anddev.cheesemp.helloandworld;
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.text.Text;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.ui.activity.BaseGameActivity;
import org.anddev.andengine.util.HorizontalAlign;
import android.graphics.Color;
import android.graphics.Typeface;
/**
* #author Nicolas Gramlich
* #since 11:54:51 - 03.04.2010
*/
public class HelloAndEngine extends BaseGameActivity
This sample is from AndEngine but I've had the same issue with every sample I modify. I can't help but feel I've missed something and nothing I found searching has helped.
Any advice appreciated!
Try this.
<activity android:label="#string/app_name" android:name=".HelloAndEngine">
You don't need the fully qualified class name. Also, if you are working with Eclipse and rename a package go to Project → Clean and let it clean up your project, fixing up references and so on if anything is broken.
This is a bug in eclipse android tools
http://code.google.com/p/android/issues/detail?id=2824
To Fix -> Right click on the project go to Android tools -> Rename application package..
And also check AndroidManifest.xml if it updated correctly, in my case it didn't, that should solve this problem