Android Maps V2 App Crashing - android

I have made an app that uses Google Android Maps API V2 and I have followed every step in the guide provided by Google but it doesn't work unfortunely and it crashes every time I try to start it up. So I'm wondering what is the problem?
MainActivity.java
package com.android.maptest;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
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:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Maptest Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.android.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.maptest.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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"
android:debuggable="true" >
<activity
android:name="com.android.maptest.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="api_key" />
</application>
</manifest>
Logcat
03-12 09:46:13.150: D/AndroidRuntime(1547): Shutting down VM
03-12 09:46:13.150: W/dalvikvm(1547): threadid=1: thread exiting with uncaught exception (group=0x410e22a0)
03-12 09:46:13.155: E/AndroidRuntime(1547): FATAL EXCEPTION: main
03-12 09:46:13.155: E/AndroidRuntime(1547): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.maptest/com.android.maptest.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-12 09:46:13.155: E/AndroidRuntime(1547): at
android.app.ActivityThread.access$600(ActivityThread.java:140)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Looper.loop(Looper.java:137)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.NativeStart.main(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.setContentView(Activity.java:1924)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.maptest.MainActivity.onCreate(MainActivity.java:11)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.performCreate(Activity.java:5206)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 11 more
03-12 09:46:13.155: E/AndroidRuntime(1547): 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
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:584)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:552)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.onCreateView(Activity.java:4849)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 20 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:574)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 23 more
03-12 09:51:21.560: I/Process(1547): Sending signal. PID: 1547 SIG: 9

Here a blog post I wrote on how to integrate Google Maps into you application:
Creating Google Map Application
From your error it look like you did not perform correctly steps 2-3 of the blog guide,
for adding Google Play services library into your application.
If you follow carefully the steps written in the guide you will end up with the end result you can see at the end of the post.

I assumed that you have already get Google Maps Android API v2 key and have Google Play services. If you not have already installed it then please follow below steps to solve this problem_
Step 1. you can found it in Android SDK Manager under Extras tick check box of -Google Play services install it and after complete installation, restart your Eclipse.
Step 2. Add library named_ google-play-services_lib found under the extras folder of your Android SDK setup folder to your Android project_
Path of google service lib_
{Your_Android_SDK_direct}\extras\google\google_play_services\libproject\google-play-services_lib
Ex. Location of this lib on My system_
C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib
I hope this will solve your ploblem.

For me adding:
import com.google.android.gms.maps.SupportMapFragment;
And changing the xml to
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/header" />
resolved the problem. I hope you resolve it too!

Looks like you didn't add the Google Play Services library to your project.
It's located at {Android SDK}\extras\google\google_play_services
Add it as Android Library Project to Eclipse and then add it to your project.

Related

Unfortunately app has stopped error eclipse? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've created an application in eclipse and it was working fine and then suddenly it keeps giving me the error message 'unfortunately app has stopped' could anyone explain where my problem lies from my log cat report as i am new to this and dont really understand what the log cat means?
03-12 12:31:03.465: D/AndroidRuntime(4997): Shutting down VM
03-12 12:31:03.465: W/dalvikvm(4997): threadid=1: thread exiting with uncaught exception (group=0x416a8930)
03-12 12:31:03.465: E/AndroidRuntime(4997): FATAL EXCEPTION: main
03-12 12:31:03.465: E/AndroidRuntime(4997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaresearchapp/com.example.softwaresearchapp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.os.Looper.loop(Looper.java:137)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-12 12:31:03.465: E/AndroidRuntime(4997): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 12:31:03.465: E/AndroidRuntime(4997): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-12 12:31:03.465: E/AndroidRuntime(4997): at dalvik.system.NativeStart.main(Native Method)
03-12 12:31:03.465: E/AndroidRuntime(4997): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.resolveActivityInfo(ActivityThread.java:1993)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:285)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost.setCurrentTab(TabHost.java:413)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost.addTab(TabHost.java:240)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.example.softwaresearchapp.MainActivity.onCreate(MainActivity.java:27)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Activity.performCreate(Activity.java:5104)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-12 12:31:03.465: E/AndroidRuntime(4997): ... 11 more
03-12 12:31:22.666: I/Process(4997): Sending signal. PID: 4997 SIG: 9`
your logcat clearly said
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Add SoftwareSearchActivity into manifest.xml like
<activity
android:name="com.example.softwaresearchapp.SoftwareSearchActivity"
android:configChanges="keyboardHidden|orientation"
android:label="SoftwareSearch"
/>
Look at this line:
3-12 12:31:03.465: E/AndroidRuntime(4997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaresearchapp/com.example.softwaresearchapp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Specifically: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Well, have you?
Each activity in your app must be declared in the manifest file. I imagine the minimum information you would want to provide would be the name and label e.g.
<activity
android:name=".SoftwareSearchActivity"
android:label="#string/title_activity_software_search"
/>
You are getting ActivityNotFoundException. Please check for Activity entry for com.example.softwaresearchapp.SoftwareSearchActivity in manifest file.

android.view.Inflate Exception, emulator says application has stopped unexpectedly

I am new to android and using google map v2 for the 1st time by looking at android developer tutorials. getting exceptions and don't know what is wrong. Can someone help me out ?
LOG CAT
03-12 22:00:01.678: D/AndroidRuntime(278): Shutting down VM
03-12 22:00:01.678: W/dalvikvm(278): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-12 22:00:01.758: E/AndroidRuntime(278): FATAL EXCEPTION: main
03-12 22:00:01.758: E/AndroidRuntime(278): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sameer.example.maps_example/com.sameer.example.maps_example.MainActivity}: android.view.InflateException: Binary XML file line #3: Error inflating class fragment
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.os.Looper.loop(Looper.java:123)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-12 22:00:01.758: E/AndroidRuntime(278): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 22:00:01.758: E/AndroidRuntime(278): at java.lang.reflect.Method.invoke(Method.java:521)
03-12 22:00:01.758: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-12 22:00:01.758: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-12 22:00:01.758: E/AndroidRuntime(278): at dalvik.system.NativeStart.main(Native Method)
03-12 22:00:01.758: E/AndroidRuntime(278): Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class fragment
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-12 22:00:01.758: E/AndroidRuntime(278): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.Activity.setContentView(Activity.java:1647)
03-12 22:00:01.758: E/AndroidRuntime(278): at com.sameer.example.maps_example.MainActivity.onCreate(MainActivity.java:11)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-12 22:00:01.758: E/AndroidRuntime(278): ... 11 more
03-12 22:00:01.758: E/AndroidRuntime(278): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.sameer.example.maps_example-2.apk]
03-12 22:00:01.758: E/AndroidRuntime(278): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-12 22:00:01.758: E/AndroidRuntime(278): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-12 22:00:01.758: E/AndroidRuntime(278): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
03-12 22:00:01.758: E/AndroidRuntime(278): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
03-12 22:00:01.758: E/AndroidRuntime(278): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
03-12 22:00:01.758: E/AndroidRuntime(278): ... 19 more
XML LAYOUT 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"/>
Java File
package com.sameer.example.maps_example;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Android Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sameer.example.maps_example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<permission
android:name="com.sameer.example.maps_example.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.sameer.example.maps_example.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:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You are writing application for API V8 but you are using MapFragment and Activity classes.
instead you should use the android-support-v4 library and use the SupportMapFragment and FragmentActvity classes.
To add the support library to the project you need to download it using the SDK Manager.
and then you can right click your project and chose Android Tools -> SupportLibrary.
Then extand your map Activity from FragmentActivity and make shure you are importing:
android.support.v4.app.FragmentActivity
in you XML file use the SupportMapFragment class instead of MapFragment, like so:
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

GoogleMap Support Fragment error

I have a project that uses the GoogleMaps API, and the support library for Fragments. I have a working map in one activity already, so I know that the API and library are all set up right. I am trying to add a map in a fragment as part of a new activity.
The activity extends an android.support.v4.app.FragmentActivity, and the xml file contains:
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="250dp"
android:name="com.google.android.gms.maps.SupportMapFragment" />
But when I run I get the error:
01-20 11:58:31.535: ERROR/AndroidRuntime(5389): 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:669)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
at android.app.Activity.setContentView(Activity.java:1835)
at com.yedidyak.gpsalarm.AddAlarm.onCreate(AddAlarm.java:19)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
All the information I can find about this error is about not having the google-play-lib properly installed both as a jar and an imported module, but I have that done - and a working map in another activity.
Any ideas?
You have to reference google play services library instead of adding jar and map_attrs.xml (and other files, like strings.xml) to your project.
If you do, you also might have deleted res/values/map_attrs.xml by accident.

Android - exception launching project on start after copying a lot of code over from another project

am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app

Error java.lang.ClassNotFoundException in my Activity using Google API in Android

I made a test a program for my University which uses Google maps following a tutorial. I made everything like in tutorial, but my app crashes before even showing anything with message "Unfortunately SocialFoot has stopped". I tried to debug and it seems like it crashes even before entering to onCreate method. This is my code:
package it.univpm.dii.socialfoot;
import com.actionbarsherlock.app.SherlockMapActivity;
import android.os.Bundle;
public class SocialFootActivity extends SherlockMapActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Logcat:
05-18 19:29:59.343: E/AndroidRuntime(3405): FATAL EXCEPTION: main
05-18 19:29:59.343: E/AndroidRuntime(3405): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{it.univpm.dii.socialfoot/it.univpm.dii.socialfoot.activities.SocialFootActivity}: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Looper.loop(Looper.java:137)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invoke(Method.java:511)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.NativeStart.main(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): Caused by: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-18 19:29:59.343: E/AndroidRuntime(3405): ... 11 more
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.univpm.dii.socialfoot"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<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_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".SocialFootActivity"
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>
Layout:
The logs indicate the app is trying to launch it.univpm.dii.socialfoot.activities.SocialFootActivity, but SocialFootActivity is in package it.univpm.dii.socialfoot. If this is happening at the start of your application (since that activity is set as the launch activity), I would try cleaning and rebuilding your project and trying again.

Categories

Resources