Google map application program crashes at the launch - android

I have been trying to add a map to my application, I have followed instructions on the android developers HelloGoogleMaps tutorial but my map is just force closing when I run the maps option. I have obtained my api key logged permissions in manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MappDemo.mymaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true" >
<activity
android:name=".MappingDemoActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<uses-library android:name="com.google.android.maps" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ShowTheMap" android:label="Lat/Long Location"> </activity>
<activity android:name=".MapMe" android:label="Track Present Location"> </activity>
<uses-library android:name="com.google.android.maps" />
<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" />
</application>
</manifest>
Can some one tell if any thing needs to be configured in addition to run the code?
03-25 11:50:52.217: I/Process(687): Sending signal. PID: 687 SIG: 9
03-25 11:51:00.557: D/AndroidRuntime(729): Shutting down VM
03-25 11:51:00.567: W/dalvikvm(729): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-25 11:51:00.627: E/AndroidRuntime(729): FATAL EXCEPTION: main
03-25 11:51:00.627: E/AndroidRuntime(729): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MappDemo.mymaps/com.MappDemo.mymaps.MappingDemoActivity}: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.os.Looper.loop(Looper.java:123)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-25 11:51:00.627: E/AndroidRuntime(729): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 11:51:00.627: E/AndroidRuntime(729): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 11:51:00.627: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-25 11:51:00.627: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-25 11:51:00.627: E/AndroidRuntime(729): at dalvik.system.NativeStart.main(Native Method)
03-25 11:51:00.627: E/AndroidRuntime(729): Caused by: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:51:00.627: E/AndroidRuntime(729): at com.MappDemo.mymaps.MappingDemoActivity.onCreate(MappingDemoActivity.java:19)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-25 11:51:00.627: E/AndroidRuntime(729): ... 11 more
03-25 11:51:10.013: I/Process(729): Sending signal. PID: 729 SIG: 9
03-25 11:52:16.817: D/AndroidRuntime(782): Shutting down VM
03-25 11:52:16.817: W/dalvikvm(782): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-25 11:52:16.877: E/AndroidRuntime(782): FATAL EXCEPTION: main
03-25 11:52:16.877: E/AndroidRuntime(782): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MappDemo.mymaps/com.MappDemo.mymaps.MappingDemoActivity}: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.os.Looper.loop(Looper.java:123)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-25 11:52:16.877: E/AndroidRuntime(782): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 11:52:16.877: E/AndroidRuntime(782): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 11:52:16.877: E/AndroidRuntime(782): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-25 11:52:16.877: E/AndroidRuntime(782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-25 11:52:16.877: E/AndroidRuntime(782): at dalvik.system.NativeStart.main(Native Method)
03-25 11:52:16.877: E/AndroidRuntime(782): Caused by: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:52:16.877: E/AndroidRuntime(782): at com.MappDemo.mymaps.MappingDemoActivity.onCreate(MappingDemoActivity.java:19)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-25 11:52:16.877: E/AndroidRuntime(782): ... 11 more
this is what I can see in logcat..
this what I have in mappingDemoActivity.java
public class MappingDemoActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//add listners for all buttons
View firstbutton= findViewById(R.id.geocode_button);
firstbutton.setOnClickListener((OnClickListener) this);
View secondButton = findViewById(R.id.latlong_button);
secondButton.setOnClickListener((OnClickListener) this);
View thirdButton = findViewById(R.id.presentLocation_button);
thirdButton.setOnClickListener((OnClickListener) this);
}
public void onClick(View v)
{
switch(v.getId())
{
case R.id.geocode_button:
Log.i("Button","Button 1 pushed");
Intent j = new Intent(this, ShowTheMap.class);
startActivity(j);
break;
case R.id.latlong_button:
Log.i("Button","Button 2 pushed");
Intent k = new Intent(this, ShowTheMap.class);
startActivity(k);
break;
case R.id.presentLocation_button:
Log.i("Button","Button 3 pushed");
Intent m = new Intent(this, MapMe.class);
startActivity(m);
break;
}
}

<uses-permission> tag needs to be a child of <manifest>, not <application>.
Try change <uses-permission> position, it can help.

Remove this code which is inside <intent-filter>
`<uses-library android:name="com.google.android.maps" />`
Because it is Already there in Below Quote.

Have a look at the Google MapsDemo that is included in the SDK my path is:
C:\android-sdk\add-ons\addon-google_apis-google_inc_-10\samples\MapsDemo
I had a quite anoying problem (MapActivity crashes on some devices) that was only showing up on certain(!) Android devices and also not in the Emulator. What I did was, to strip down the working demo until it was similar to my basic example. Then it turned out that Samsung phones don't accept package names not starting with com., while other devices (HTC Flyer) do! But this is not your problem, since you are using a com. package name.
There might be one more thing that comes to my mind. You didn't post your main.xml. If you use a nested LinearLayout below the MapView this also crashes the app. On top of the MapView it works fine. So in case you are using something like:
<LinearLayout ... >
<com.google.android.maps.MapView ... />
<LinearLayout ... >
<Button .../>
</LinearLayout>
</LinearLayout>
This could cause your problem. This is reproducable and throws exactly the same java.lang.ClassCastException error.
Also be sure to have your < uses-permission > and < uses-library > statements in the right place, as the guys said before. The first one must be a direct child of the < manifest > node. The second one must be a direct child of the < application > node.
I hope this helps you. I was going crazy with this stuff.
Bernd

Related

android manifest fullscreen causes my app crash

Made My first app. Just after creating I tried make it Full screen. It says "Unfortunately your app has been stopped."
Android manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nirmal.projectfullscreen">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActiviy.java
package com.example.nirmal.projectfullscreen;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
logcat
03-25 22:05:14.257 5289-5289/com.example.nirmal.projectfullscreen E/Trace: error opening trace file: No such file or directory (2)
03-25 22:05:14.427 5289-5289/com.example.nirmal.projectfullscreen W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
03-25 22:05:14.427 5289-5289/com.example.nirmal.projectfullscreen W/dalvikvm: VFY: unable to resolve interface method 15038: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
03-25 22:05:14.427 5289-5289/com.example.nirmal.projectfullscreen W/dalvikvm: VFY: unable to resolve interface method 15042: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
03-25 22:05:14.437 5289-5289/com.example.nirmal.projectfullscreen W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41f3c600)
03-25 22:05:14.437 5289-5289/com.example.nirmal.projectfullscreen E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nirmal.projectfullscreen/com.example.nirmal.projectfullscreen.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5578)
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:1074)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:340)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:273)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.nirmal.projectfullscreen.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5066)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5578)
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:1074)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841)
at dalvik.system.NativeStart.main(Native Method)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: killProcess, pid=5289
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: dalvik.system.VMStack.getThreadStackTrace(Native Method)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: java.lang.Thread.getStackTrace(Thread.java:599)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: android.os.Process.killProcess(Process.java:956)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-25 22:05:17.087 5289-5289/com.example.nirmal.projectfullscreen D/Process: dalvik.system.NativeStart.main(Native Method)
You are using AppCompatActivity and thus your theme should inherit Theme.AppCompat.
You need to use a Theme.AppCompat theme (or descendant) with this activity.
Use this theme:
<style name="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
In your manifest:
android:theme="#style/AppFullScreenTheme"

Activity does not have a parent activity name specified

I have a wishlist in menu.xml. I click on wishlist menu item and the activity is opened but when click the back arrow in the top. I am getting the following error:
03-25 01:13:28.278: E/NavUtils(15464): getParentActivityIntent: bad parentActivityName 'com.ylg.link.Ylg_GridViewActivity' in manifest
03-25 01:13:28.278: D/AndroidRuntime(15464): Shutting down VM
03-25 01:13:28.278: W/dalvikvm(15464): threadid=1: thread exiting with uncaught exception (group=0x417c3700)
03-25 01:13:28.286: E/AndroidRuntime(15464): FATAL EXCEPTION: main
03-25 01:13:28.286: E/AndroidRuntime(15464): java.lang.IllegalArgumentException: Activity Ylg_Wishlist does not have a parent activity name specified. (Did you forget to add the android.support.PARENT_ACTIVITY <meta-data> element in your manifest?)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.support.v4.app.NavUtils.navigateUpFromSameTask(NavUtils.java:178)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.ylg.link.Ylg_Wishlist.onOptionsItemSelected(YLG_Wishlist.java:47)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.app.Activity.onMenuItemSelected(Activity.java:2566)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.android.internal.widget.ActionBarView$3.onClick(ActionBarView.java:171)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.view.View.performClick(View.java:4240)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.view.View$PerformClick.run(View.java:17721)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.os.Handler.handleCallback(Handler.java:730)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.os.Handler.dispatchMessage(Handler.java:92)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.os.Looper.loop(Looper.java:137)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.app.ActivityThread.main(ActivityThread.java:5103)
03-25 01:13:28.286: E/AndroidRuntime(15464): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 01:13:28.286: E/AndroidRuntime(15464): at java.lang.reflect.Method.invoke(Method.java:525)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-25 01:13:28.286: E/AndroidRuntime(15464): at dalvik.system.NativeStart.main(Native Method)
Please not that Parent_Acitivty is a fragment. And I have the below intent in the FragmentActivity
Intent intent = new Intent(this, Ylg_Wishlist.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
When I click on the back top button it should direct me to fragment but instead i am getting the above error.
Here is the manifest I am declaring:
<activity
android:name="com.ylg.link.Ylg_Wishlist"
android:label="#string/wishlist"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.ylg.link.Ylg_GridViewActivity" />
</activity>
Can somebody help me fix this? How do I call the back button to call the fragment rather an activity?
Thanks!
Make sure that com.ylg.link.Ylg_GridViewActivity is an activity and not a fragment, you can only specify Activities in the android.support.PARENT_ACTIVITY meta data.
Also, I find it a bit odd that the name is com.ylg.link.Ylg_GridViewActivity in the manifest and com.ylg.link.ylg_GridViewActivity in the stack trace (different case for the letter 'Y' in ylg_GridViewActivity). It could also be related to your problem.

the application gmaps(com.formation.gmaps) has stopped unexpectdly

I am trying to create an application location, but it shows me the error the application of gmaps (com.formation.gmaps) has stopped unexpectedly.
Note that I have already uninstalled eclipse but always this error appears.
Here is my Error log:
03-25 14:21:59.914: E/AndroidRuntime(431): FATAL EXCEPTION: main
03-25 14:21:59.914: E/AndroidRuntime(431): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.formation.gmaps/com.formation.gmaps.MainActivity}: java.lang.ClassNotFoundException: com.formation.gmaps.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.formation.gmaps-1.apk]
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.os.Looper.loop(Looper.java:123)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-25 14:21:59.914: E/AndroidRuntime(431): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 14:21:59.914: E/AndroidRuntime(431): at java.lang.reflect.Method.invoke(Method.java:521)
03-25 14:21:59.914: E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-25 14:21:59.914: E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-25 14:21:59.914: E/AndroidRuntime(431): at dalvik.system.NativeStart.main(Native Method)
03-25 14:21:59.914: E/AndroidRuntime(431): Caused by: java.lang.ClassNotFoundException: com.formation.gmaps.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.formation.gmaps-1.apk]
03-25 14:21:59.914: E/AndroidRuntime(431): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-25 14:21:59.914: E/AndroidRuntime(431): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-25 14:21:59.914: E/AndroidRuntime(431): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-25 14:21:59.914: E/AndroidRuntime(431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
03-25 14:21:59.914: E/AndroidRuntime(431): ... 11 more
This is MainActivity.java
package com.formation.gmaps;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity {
#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.activity_main, menu);
return true;
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
This is AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.formation.gmaps.MainActivity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<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_MOCK_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_GPS"/>
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.formation.gmaps.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>
The system cannot find the MainActivity.class in your com.formation.gmaps package. This can be caused by many things but you can check if:
1. You declared your activity com.formation.gmaps.MainActivity in your AndroidManifest.xml.
2. Your MainActivity.java has the correct package name set in the top of the file (e.g package com.formation.gmaps).
3. You should have import com.formation.gmaps.R;
4. Use the shortcut CTRL + SHIFT + O in Eclipse. This will import any missing classes.
5. A Project -> Clean could also help(provided you're using Eclipse).
EDIT
In your AndroidManifest.xml change package="com.formation.gmaps.MainActivity" to package="com.formation.gmaps".
EDIT 02
Your problem is your MapActivity.java. Read this. If you used the latest API then this paragraph explains it:
Because maps are encapsulated in the MapFragment class, you can
implement them by extending the Android standard Activity class,
rather than extending the MapActivity used in version 1.
So please check your MapActivity.class. If it extends Fragment then the problem is there. You can test this by changing your MainActivity to extent Activity instead of MapActivity. Do not forget to add import android.app.Activity;
If you're still using V1 of Maps then read the documentation on the link I have provided and switch to V2. You might still be using the old version which requires the process of importing a maps.jar.
This might help you as well.
Good luck and let us know if you run into more trouble.

Ksoap2 Error after Updating Android SDK and ADT

I have a problem.
When I updated Android SDK tool to version 17 and the ADT to 17 I can't use ksoap2 any more.
I start the app and get this error:
03-25 20:13:49.995: E/AndroidRuntime(555): FATAL EXCEPTION: main
03-25 20:13:49.995: E/AndroidRuntime(555): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
03-25 20:13:49.995: E/AndroidRuntime(555): at com.alcad.pernat.praksa.SplashScreen.pridobiDanasnjo(SplashScreen.java:124)
03-25 20:13:49.995: E/AndroidRuntime(555): at com.alcad.pernat.praksa.SplashScreen.onCreate(SplashScreen.java:73)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.os.Looper.loop(Looper.java:123)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-25 20:13:49.995: E/AndroidRuntime(555): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 20:13:49.995: E/AndroidRuntime(555): at java.lang.reflect.Method.invoke(Method.java:521)
03-25 20:13:49.995: E/AndroidRuntime(555): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-25 20:13:49.995: E/AndroidRuntime(555): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-25 20:13:49.995: E/AndroidRuntime(555): at dalvik.system.NativeStart.main(Native Method)
I should get String with some numbers but instead I get this error.
I was using ksoap2-2.5.4.jar and tried the new ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar.
I'm using Eclipse indigo, Ubuntu 11.04.
The code looks like this:
SoapObject Request =new SoapObject(NAMESPACE,METHOD_NAME); // Here I get the error
SoapSerializationEnvelope soapEnvelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=false;
String tmp=odstejDatum(datum);
Request.addProperty("datumod",tmp);
Request.addProperty("datumdo",datum);
Request.addProperty("tip_lme",1);
#SuppressWarnings("deprecation")
HttpTransportSE aht=new HttpTransportSE(URL,5000);
soapEnvelope.setOutputSoapObject(Request);
//
aht.call(SOAP_ACTION_DANASNJI,soapEnvelope);
Object response= soapEnvelope.getResponse();
Thanks for the help.
Android SDK tool to version 17 and the ADT to 17 they changed lib structure more details.
Here is the fix:
Remove the "ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar"
from the build path.
copy the jar file into libs folder
(if not exist create it), then remove jar file from your folder(if you have custom jar folder in your project).
it will automatically take it in the build path.then, clean your project and run.

Work with Android Library GreenDroid

I want to use the GreenDroid library in my application.
I added it as a library in the project settings.
My XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.tvbrain"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.GreenDroid"
android:name=".TVBrainApplication">>
<activity
android:label="#string/app_name"
android:name=".TVBrainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
TVBrainActivity:
public class TVBrainActivity extends GDActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActionBarContentView(R.layout.gd_action_bar_empty);
}
}
Application Class:
public class AppBrainApplication extends GDApplication{
#Override
public Class<?> getHomeActivityClass() {
return AppBrainApplication.class;
}
}
Error Log:
10-24 10:25:55.265: E/AndroidRuntime(524): Uncaught handler: thread main exiting due to uncaught exception
10-24 10:25:55.295: E/AndroidRuntime(524): java.lang.RuntimeException: Unable to instantiate application com.korn.tvbrain.TVBrainApplication: java.lang.ClassNotFoundException: com.korn.tvbrain.TVBrainApplication in loader dalvik.system.PathClassLoader#44bfd908
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:523)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3996)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread.access$2900(ActivityThread.java:119)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1901)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.os.Looper.loop(Looper.java:123)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread.main(ActivityThread.java:4363)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.reflect.Method.invoke(Method.java:521)
10-24 10:25:55.295: E/AndroidRuntime(524): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-24 10:25:55.295: E/AndroidRuntime(524): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-24 10:25:55.295: E/AndroidRuntime(524): at dalvik.system.NativeStart.main(Native Method)
10-24 10:25:55.295: E/AndroidRuntime(524): Caused by: java.lang.ClassNotFoundException: com.korn.tvbrain.TVBrainApplication in loader dalvik.system.PathClassLoader#44bfd908
10-24 10:25:55.295: E/AndroidRuntime(524): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.Instrumentation.newApplication(Instrumentation.java:942)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:518)
10-24 10:25:55.295: E/AndroidRuntime(524): ... 11 more
I always get a ClassNotFound Exception.
In application tag in AndroidManifest file I guess android:name=".TVBrainApplication" here the name should be android:name=".AppBrainApplication"
It looks like you should add android:name=".AppBrainApplication" instead of android:name=".TVBrainApplication" in your AndroidManifest

Categories

Resources