Work with Android Library GreenDroid - android

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

Related

Android manifest file activity error

12-11 02:45:59.232: E/AndroidRuntime(348): FATAL EXCEPTION: main
12-11 02:45:59.232: E/AndroidRuntime(348): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ass.ui/com.ass.ui.Settings}: java.lang.InstantiationException: com.ass.ui.Settings
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.os.Handler.dispatchMessage(Handler.java:99)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.os.Looper.loop(Looper.java:123)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-11 02:45:59.232: E/AndroidRuntime(348): at java.lang.reflect.Method.invokeNative(Native Method)
12-11 02:45:59.232: E/AndroidRuntime(348): at java.lang.reflect.Method.invoke(Method.java:521)
12-11 02:45:59.232: E/AndroidRuntime(348): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-11 02:45:59.232: E/AndroidRuntime(348): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-11 02:45:59.232: E/AndroidRuntime(348): at dalvik.system.NativeStart.main(Native Method)
12-11 02:45:59.232: E/AndroidRuntime(348): Caused by: java.lang.InstantiationException: com.ass.ui.Settings
12-11 02:45:59.232: E/AndroidRuntime(348): at java.lang.Class.newInstanceImpl(Native Method)
12-11 02:45:59.232: E/AndroidRuntime(348): at java.lang.Class.newInstance(Class.java:1429)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-11 02:45:59.232: E/AndroidRuntime(348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-11 02:45:59.232: E/AndroidRuntime(348): ... 11 more
this is my Logcat error, and below is the android manifest file. This works yesterday and i havent changed a single letter and the error persists now.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ass.ui"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ass.ui.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.ass.ui.Settings"
android:configChanges="orientation"
android:label="#string/app_name"
android:noHistory="true"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
Seems I cant see where Im wrong here. Tnx for a help.
The problem lies with your Java class, not the configuration. Most probably your activity class has no public empty constructor or it is abstract.

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.

Android: Recource$NotFoundException

Im working with android, and am releatively new to it, Ive got an exception I cant seem to fix.
Logcat output
10-24 13:50:59.941: E/AndroidRuntime(772): FATAL EXCEPTION: main
10-24 13:50:59.941: E/AndroidRuntime(772): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.metronome/com.metronome.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x78
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.access$600(ActivityThread.java:122)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.os.Looper.loop(Looper.java:137)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.main(ActivityThread.java:4340)
10-24 13:50:59.941: E/AndroidRuntime(772): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 13:50:59.941: E/AndroidRuntime(772): at java.lang.reflect.Method.invoke(Method.java:511)
10-24 13:50:59.941: E/AndroidRuntime(772): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-24 13:50:59.941: E/AndroidRuntime(772): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-24 13:50:59.941: E/AndroidRuntime(772): at dalvik.system.NativeStart.main(Native Method)
10-24 13:50:59.941: E/AndroidRuntime(772): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x78
10-24 13:50:59.941: E/AndroidRuntime(772): at android.content.res.Resources.getText(Resources.java:247)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.widget.TextView.setText(TextView.java:3432)
10-24 13:50:59.941: E/AndroidRuntime(772): at com.metronome.MainActivity.onCreate(MainActivity.java:36)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.Activity.performCreate(Activity.java:4465)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
10-24 13:50:59.941: E/AndroidRuntime(772): ... 11 more
Ive read that people say to fix the problem by cleaning the project but I have tried that twice and it didnt help. I also creted another project and copied the code, so I think it is something different. Any help is appreciated.
Line 36
txtBPM1.setText(120, TextView.BufferType.EDITABLE);
This error occurs when you access some controls or which is not present in your layout you pass on onCreate in you activity setContentView(R.layout.your_layout);. Just checkout all the id's , string's and other controls which you are using belongs to same layout or not
change 120 to be a string like so :
txtBPM1.setText(""+120, TextView.BufferType.EDITABLE);
(your error in MainActivity.java:line 36 (it is import generated R))
1.delete error line from import and use pop-up message on red R.id.**
2. close and reopen IDE

Google map application program crashes at the launch

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

Unable to load webpage using WebView in Android

I have recently taken up Android Development and I was looking to using the WebView display webpages. I picked up from the sample that was given on Google site and for some reason the emulator kept saying page was not available. I searched in StackOverflow and found links relating to WebViewClient. I tried that also but no luck there, I have checked multiple times about the manifest entry for internet permission and its there. As a test I ran the browser available within the emulator and sure enough my firewall popped up a question on whether to allow it access or not. The pop up never came to me when I was running it from program. The code that I have is what is there Google pages
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
mWebView.setWebViewClient(new HelloWebViewClient());
private class HelloWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
I tried loading simple html directly using loadData and it worked fine. I am at loss as to what is happening and how this can be resolved. I would appreciate any help on this.
Adding the Android Manifest here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
</application>
</manifest>
To check if its just a WebView thingy, I tried accessing the internet using httpGet and httpResonse classes and got the same problem, the code was not able to connect to the given site. It failed stating the below
05-10 00:37:53.191: WARN/System.err(294): java.net.UnknownHostException: feeds.feedburner.com
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.getAllByName(InetAddress.java:242)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-10 00:37:53.271: WARN/System.err(294): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
05-10 00:37:53.271: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-10 00:37:53.280: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-10 00:37:53.291: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-10 00:37:53.301: WARN/System.err(294): at com.example.hellowebview.HelloWebView.onCreate(HelloWebView.java:43)
05-10 00:37:53.301: WARN/System.err(294): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-10 00:37:53.309: WARN/System.err(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-10 00:37:53.322: WARN/System.err(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-10 00:37:53.330: WARN/System.err(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-10 00:37:53.340: WARN/System.err(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-10 00:37:53.350: WARN/System.err(294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-10 00:37:53.350: WARN/System.err(294): at android.os.Looper.loop(Looper.java:123)
05-10 00:37:53.361: WARN/System.err(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 00:37:53.361: WARN/System.err(294): at java.lang.reflect.Method.invokeNative(Native Method)
05-10 00:37:53.372: WARN/System.err(294): at java.lang.reflect.Method.invoke(Method.java:521)
05-10 00:37:53.380: WARN/System.err(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 00:37:53.380: WARN/System.err(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 00:37:53.401: WARN/System.err(294): at dalvik.system.NativeStart.main(Native Method)
05-10 00:37:56.773: WARN/ActivityManager(58): Launch timeout has expired, giving up wake lock!
05-10 00:37:58.083: WARN/ActivityManager(58): Activity idle timeout for HistoryRecord{44fc9108 com.example.hellowebview/.HelloWebView}
05-10 00:38:06.300: DEBUG/KeyguardViewMediator(58): pokeWakelock(5000)
05-10 00:38:06.651: INFO/ARMAssembler(58): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x3724c8:0x3725d4] in 7266287 ns
05-10 00:38:06.720: INFO/ARMAssembler(58): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x371380:0x371548] in 1486222 ns
05-10 00:38:30.430: DEBUG/AndroidRuntime(294): Shutting down VM
05-10 00:38:30.430: WARN/dalvikvm(294): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): FATAL EXCEPTION: main
05-10 00:38:30.752: ERROR/AndroidRuntime(294): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hellowebview/com.example.hellowebview.HelloWebView}: java.lang.NullPointerException
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.os.Looper.loop(Looper.java:123)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invokeNative(Native Method)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invoke(Method.java:521)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at dalvik.system.NativeStart.main(Native Method)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): Caused by: java.lang.NullPointerException
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.example.hellowebview.HelloWebView.onCreate(HelloWebView.java:51)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): ... 11 more
Got it. For some reason the order in which the permission is set matters a lot. I changed the order of my permission setting in manifest file and it worked. Here's the modified manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am not sure what is the significance of this but would appreciate if anyone could elaborate.
Got it. For some reason the order in which the permission is set matters a lot. I changed the order of my permission setting in manifest file and it worked. Here's the modified manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
mWebView = (WebView) findViewById(R.id.webview);
WebSettings setting =mWebView.getSettings();
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
mWebView.loadUrl("http://www.google.com");
Use this code .shouldOverrideUrlLoading() not use compulsary.use this code and please reply me this code work or not
Your code looks fine. I would make sure internet is working correctly on the emulator by browsing a few pages on the Android Browser. I have had problems before where the emulator would lose network access.

Categories

Resources