Android Map Application has stopped unexpectedly - android

I am working on an Android Project of using goolge map.
But when I try to run it on a tablet or HTC phone, it says the application has stopped unexpectedly. What kind of setting do I need to do, like adding library files and etc.
I have used my API key as well, so if this apps runs on a device, can I view the map or only the grid? what do we mean by signing the app?
MainActivity.java
package com.sulav.maptravis2;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends MapActivity {
MapView map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
map=(MapView) findViewById(R.id.mvMain);
map.setBuiltInZoomControls(true);
}
catch(Exception e){}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/mvMain"
android:apiKey="AIzaSyBxPKfOUpiOK981HFNcXi6szt0Dn__tQko"
/>
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sulav.maptravis2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<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.sulav.maptravis2.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>
logcat output:
05-24 12:06:46.285: I/dalvikvm(7686): Could not find method android.security.MessageDigest.getInstance, referenced from method com.google.android.maps.KeyHelper.getSignatureFingerprint
05-24 12:06:46.285: W/dalvikvm(7686): VFY: unable to resolve static method 153: Landroid/security/MessageDigest;.getInstance (Ljava/lang/String;)Landroid/security/MessageDigest;
05-24 12:06:46.285: D/dalvikvm(7686): VFY: replacing opcode 0x71 at 0x0038
05-24 12:06:46.295: D/AndroidRuntime(7686): Shutting down VM
05-24 12:06:46.295: W/dalvikvm(7686): threadid=1: thread exiting with uncaught exception (group=0x409fe1f8)
05-24 12:06:46.305: E/AndroidRuntime(7686): FATAL EXCEPTION: main
05-24 12:06:46.305: E/AndroidRuntime(7686): java.lang.NoClassDefFoundError: android.security.MessageDigest
05-24 12:06:46.305: E/AndroidRuntime(7686): at com.google.android.maps.KeyHelper.getSignatureFingerprint(KeyHelper.java:60)
05-24 12:06:46.305: E/AndroidRuntime(7686): at com.google.android.maps.MapActivity.createMap(MapActivity.java:552)
05-24 12:06:46.305: E/AndroidRuntime(7686): at com.google.android.maps.MapActivity.onCreate(MapActivity.java:422)
05-24 12:06:46.305: E/AndroidRuntime(7686): at com.sulav.maptravis2.MainActivity.onCreate(MainActivity.java:13)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.Activity.performCreate(Activity.java:4465)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.os.Looper.loop(Looper.java:137)
05-24 12:06:46.305: E/AndroidRuntime(7686): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-24 12:06:46.305: E/AndroidRuntime(7686): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 12:06:46.305: E/AndroidRuntime(7686): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 12:06:46.305: E/AndroidRuntime(7686): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-24 12:06:46.305: E/AndroidRuntime(7686): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-24 12:06:46.305: E/AndroidRuntime(7686): at dalvik.system.NativeStart.main(Native Method)

Not sure if you just failed to paste it in but it appears your layout is missing this at the top.
<?xml version="1.0" encoding="utf-8"?>
Regardless check this link out:
What is 'android.security.MessageDigest''?

Related

App crashes if I extend FragmentActivity

I have been trying to extend FragmentActivity. The same app works if I extend the MainActivity class to Activity and import necessary packages for a normal Activity.
The basic need is that i cannot access the map in a normal activity. It needs to extend FragmentActivity to run the following line.
googleMap= ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
Here is the Java code
package com.dacoders.locationtodo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_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;
}
}
Here is the layout XML
<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"/>
Here is the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dacoders.locationtodo"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.dacoders.locationtodo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.dacoders.locationtodo.permission.MAPS_RECEIVE"/>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<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.dacoders.locationtodo.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_HERE"/>
</application>
</manifest>
Here is the LOG
0622 21:01:25.911: D/dalvikvm(13621): Lateenabling CheckJNI
0622 21:01:25.991: D/AndroidRuntime(13621): Shutting down VM
0622 21:01:25.991: W/dalvikvm(13621): threadid=1: thread exiting with uncaught exception (group=0x41629930)
0622 21:01:26.001: E/AndroidRuntime(13621): FATAL EXCEPTION: main
0622 21:01:26.001: E/AndroidRuntime(13621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dacoders.locationtodo/com.dacoders.locationtodo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.access$600(ActivityThread.java:141)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.os.Handler.dispatchMessage(Handler.java:99)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.os.Looper.loop(Looper.java:137)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.main(ActivityThread.java:5041)
0622 21:01:26.001: E/AndroidRuntime(13621): at java.lang.reflect.Method.invokeNative(Native Method)
0622 21:01:26.001: E/AndroidRuntime(13621): at java.lang.reflect.Method.invoke(Method.java:511)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
0622 21:01:26.001: E/AndroidRuntime(13621): at dalvik.system.NativeStart.main(Native Method)
0622 21:01:26.001: E/AndroidRuntime(13621): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.Activity.setContentView(Activity.java:1881)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.dacoders.locationtodo.MainActivity.onCreate(MainActivity.java:12)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.Activity.performCreate(Activity.java:5104)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
0622 21:01:26.001: E/AndroidRuntime(13621): ... 11 more
0622 21:01:26.001: E/AndroidRuntime(13621): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
0622 21:01:26.001: E/AndroidRuntime(13621): at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
0622 21:01:26.001: E/AndroidRuntime(13621): ... 20 more
Here is the layout XML
<fragment
I'm not sure if you can have a fragment as the root of your layout as fragments are supposed to be pieces that are put in another layout and exchanged.
Have you tried putting your fragment in a FrameLayout and see if it still crashes?
Your min sdk is 11. I guess you can make it 12 and use MapFragment.
To know why check the link http://developer.android.com/about/dashboards/index.html.
In that case (minsdk is 12 or above) you can extend Activity
GoogleMap mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Also import
import com.google.android.gms.maps.MapFragment;
Or
You should use Support Fragment.
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Your activity must extend FragmentActivity
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap mMap = fm.getMap();
Make sure you have added support library
Also make sure you imported the below
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.SupportMapFragment;

android.content.ActivityNotFoundException, unable to start activity

I have a problem with the Manifest of my Application.
Clicking on a button on Main activity I want to start an other Activity, so I used this function:
public void startDatacenters() {
Intent intent = new Intent(context, Datacenters.class);
activity.startActivity(intent);}
The package of Datacenters.class is com.eco4cloud.activities.Datacenters
So my manifest is this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eco4cloud"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".activities.Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.Datacenters"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.eco4cloud.activities.DATACENTERS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Android gave me this error i don't know why :(
05-24 18:01:32.622: D/AndroidRuntime(15404): Shutting down VM
05-24 18:01:32.622: W/dalvikvm(15404): threadid=1: thread exiting with uncaught exception (group=0x40a441f8)
05-24 18:01:32.632: E/AndroidRuntime(15404): FATAL EXCEPTION: main
05-24 18:01:32.632: E/AndroidRuntime(15404): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eco4cloud/com.eco4cloud.activities.Main}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.eco4cloud/com.eco4cloud.activities.Datacenters}; have you declared this activity in your AndroidManifest.xml?
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.ActivityThread.access$600(ActivityThread.java:132)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.os.Looper.loop(Looper.java:137)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.ActivityThread.main(ActivityThread.java:4575)
05-24 18:01:32.632: E/AndroidRuntime(15404): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 18:01:32.632: E/AndroidRuntime(15404): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 18:01:32.632: E/AndroidRuntime(15404): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
05-24 18:01:32.632: E/AndroidRuntime(15404): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-24 18:01:32.632: E/AndroidRuntime(15404): at dalvik.system.NativeStart.main(Native Method)
05-24 18:01:32.632: E/AndroidRuntime(15404): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.eco4cloud/com.eco4cloud.activities.Datacenters}; have you declared this activity in your AndroidManifest.xml?
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.Activity.startActivityForResult(Activity.java:3190)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.Activity.startActivity(Activity.java:3297)
05-24 18:01:32.632: E/AndroidRuntime(15404): at com.eco4cloud.controllers.MainController.startDatacenters(MainController.java:46)
05-24 18:01:32.632: E/AndroidRuntime(15404): at com.eco4cloud.activities.Main.verifyAndSignIn(Main.java:117)
05-24 18:01:32.632: E/AndroidRuntime(15404): at com.eco4cloud.activities.Main.onCreate(Main.java:53)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.Activity.performCreate(Activity.java:4465)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-24 18:01:32.632: E/AndroidRuntime(15404): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
05-24 18:01:32.632: E/AndroidRuntime(15404): ... 11 more
Someone can help me??
I don't know if the problem is with the package name or others things :(
I am not sure what you are trying to do.
But a couple of suggestions to try.
package="com.eco4cloud.activities"
// make sure package name is right.
// probably it should be as above.
Mention the package name as above
Since you have explicit intent you don't require a intent-filter
// use this assuming Datacenters is in package com.eco4cloud.activities
// also assuming package="com.eco4cloud.activities"
<activity
android:name=".Datacenters"
android:label="#string/app_name" >
</activity>
If package="com.eco4cloud" try the below
<activity
android:name="com.eco4cloud.activities.Datacenters"
android:label="#string/app_name" >
</activity>
If you are starting a activity in a non-activity class
public void startDatacenters() {
Intent intent = new Intent(context, Datacenters.class);
// assuming context is the activity content
context.startActivity(intent);
//in your case you have activity.startActivity(intent)
// not sure what activity is
}
try providing the fully qualified name of the activity in the app manifest "com.eco4cloud.activities.Datacenters" instead of just ".activities.Datacenters"
you can use like that
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eco4cloud"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.eco4cloud.activities.Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.eco4cloud.activities.Datacenters"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.eco4cloud.activities.DATACENTERS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

NoClassDefFoundError Due to Google Maps v2

I have recently had to update my SDK and ADT and since then I have been having loads of trouble with existing applications. My problem is that with one of my applications I am getting the following error:
05-24 09:13:49.234: E/AndroidRuntime(7064): FATAL EXCEPTION: main
05-24 09:13:49.234: E/AndroidRuntime(7064): java.lang.NoClassDefFoundError: com.taxi.cabfind.Map_Location
05-24 09:13:49.234: E/AndroidRuntime(7064): at com.taxi.cabfind.Pickup_Address$5.onClick(Pickup_Address.java:239)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.view.View.performClick(View.java:4204)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.view.View$PerformClick.run(View.java:17355)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.os.Handler.handleCallback(Handler.java:725)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.os.Looper.loop(Looper.java:137)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-24 09:13:49.234: E/AndroidRuntime(7064): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 09:13:49.234: E/AndroidRuntime(7064): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 09:13:49.234: E/AndroidRuntime(7064): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-24 09:13:49.234: E/AndroidRuntime(7064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-24 09:13:49.234: E/AndroidRuntime(7064): at dalvik.system.NativeStart.main(Native Method)
This is occurring when I am trying to load up a fragment activity that contains maps v2.
This is confusing to me because in another application that I have, there is maps v2 code inside this app and this app has no problems with it. I have checked all the settings and made sure that everything matches, but I am still getting this crash.
Can someone please help.
EDIT
In changing the project and placing the google-play-services-lib.jar file in the libs folder I am now getting the following error
05-24 09:35:27.169: E/AndroidRuntime(11672): FATAL EXCEPTION: main
05-24 09:35:27.169: E/AndroidRuntime(11672): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.Activity.setContentView(Activity.java:1881)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.taxi.cabfind.Map_Location.onCreate(Map_Location.java:81)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.Activity.performCreate(Activity.java:5104)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.os.Looper.loop(Looper.java:137)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-24 09:35:27.169: E/AndroidRuntime(11672): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 09:35:27.169: E/AndroidRuntime(11672): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-24 09:35:27.169: E/AndroidRuntime(11672): at dalvik.system.NativeStart.main(Native Method)
This is now exactly the same as my other project that is working, I am really confused at why this one isn't working
You should not place the jar in libs folder.
You should google play services library project in your android project.
Import library project into workspace and eclipse.
Right click on your android project. goto properties. Choose android. click add. Browse the library project and add the same.
Now if you have updated adt to rev 22.
java.lang.ClassNotFoundException after changing nothing in the project but upgrading eclipse android sdk
to check if its a library project. right click on your google play services library goto properties choose android. You will see Is Library check box checked
After adding it looks similar to the one below
I upgrate SDK and ADT(ver22) yesterday just like you .
And have same error
I try this and it's work ...

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