I'm new to developing for Android and I'm having trouble launching my project. Whenever I launch it, it crashes and I get an error. I've put breakpoints throughout my code but it crashes before it reaches them. Here is the output from LogCat:
07-18 18:22:17.695: I/System.out(32229): Sending WAIT chunk
07-18 18:22:17.695: W/ActivityThread(32229): Application com.amvara.skatometer is waiting for the debugger on port 8100...
07-18 18:22:17.945: I/dalvikvm(32229): Debugger is active
07-18 18:22:18.095: I/System.out(32229): Debugger has connected
07-18 18:22:18.095: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.295: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.500: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.700: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.900: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.100: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.300: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.500: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.705: I/System.out(32229): debugger has settled (1434)
07-18 18:22:19.735: W/dalvikvm(32229): Unable to resolve superclass of Lcom/amvara/skatometer/ItemListActivity; (29)
07-18 18:22:19.735: W/dalvikvm(32229): Link of class 'Lcom/amvara/skatometer/ItemListActivity;' failed
07-18 18:22:19.745: D/AndroidRuntime(32229): Shutting down VM
07-18 18:22:19.745: W/dalvikvm(32229): threadid=1: thread exiting with uncaught exception (group=0x410d62a0)
07-18 18:22:19.780: E/AndroidRuntime(32229): FATAL EXCEPTION: main
07-18 18:22:19.780: E/AndroidRuntime(32229): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.amvara.skatometer/com.amvara.skatometer.ItemListActivity}: java.lang.ClassNotFoundException: com.amvara.skatometer.ItemListActivity
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.access$600(ActivityThread.java:140)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.os.Looper.loop(Looper.java:137)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.main(ActivityThread.java:4898)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 18:22:19.780: E/AndroidRuntime(32229): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
07-18 18:22:19.780: E/AndroidRuntime(32229): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
07-18 18:22:19.780: E/AndroidRuntime(32229): at dalvik.system.NativeStart.main(Native Method)
07-18 18:22:19.780: E/AndroidRuntime(32229): Caused by: java.lang.ClassNotFoundException: com.amvara.skatometer.ItemListActivity
07-18 18:22:19.780: E/AndroidRuntime(32229): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.Instrumentation.newActivity(Instrumentation.java:1057)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
07-18 18:22:19.780: E/AndroidRuntime(32229): ... 11 more
I can't figure out why this would happen because it isn't even hitting a breakpoint in my code. It must be a problem in the auto-generated Android code. Here's my AndroidManifest.xml, if you need it:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amvara.skatometer"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.amvara.skatometer.ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.amvara.skatometer.ItemDetailActivity"
android:label="#string/title_item_detail"
android:parentActivityName=".ItemListActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ItemListActivity" />
</activity>
<activity
android:name="com.amvara.skatometer.Bottom_panel"
android:label="#string/title_activity_bottom_panel" >
</activity>
<activity
android:name="com.amvara.skatometer.General"
android:label="#string/title_activity_general" >
</activity>
<activity
android:name="com.amvara.skatometer.SettingsActivity"
android:label="#string/title_activity_settings" >
</activity>
</application>
</manifest>
Thanks.
Try to clean your project, then you can also change :
<activity
android:name="com.amvara.skatometer.ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
[...]
</activity>
By
<activity
android:name=".ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
[...]
</activity>
It append to me one time but after all modification, doesn't work so I recreate the project from scratch and imported all my class, layout, etc. At the end, works as well.
Related
I'm trying to run this code (android app):
manifest file:
<<<<<<< Original
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testamish"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Results"
android:label="#string/title_activity_results" >
</activity>
<activity
android:name=".SpinnerDemo"
android:label="#string/title_activity_spinner_demo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity android:name="com.example.testamish.MainActivity"
android:label="#string/title_activity_main"
>
</activity>
</application>
</manifest>
>>>>>>> Added
However, when trying to launch this on a virtual device, I get those errors and I don't get why (code has no errors/warnings):
10-17 17:07:22.685: E/Trace(819): error opening trace file: No such file or directory (2)
10-17 17:07:23.430: D/AndroidRuntime(819): Shutting down VM
10-17 17:07:23.430: W/dalvikvm(819): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
10-17 17:07:23.445: E/AndroidRuntime(819): FATAL EXCEPTION: main
10-17 17:07:23.445: E/AndroidRuntime(819): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.testamish/com.example.testamish.MainActivity}: java.lang.ClassNotFoundException: com.example.testamish.MainActivity
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.os.Looper.loop(Looper.java:137)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.reflect.Method.invokeNative(Native Method)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.reflect.Method.invoke(Method.java:511)
10-17 17:07:23.445: E/AndroidRuntime(819): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-17 17:07:23.445: E/AndroidRuntime(819): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-17 17:07:23.445: E/AndroidRuntime(819): at dalvik.system.NativeStart.main(Native Method)
10-17 17:07:23.445: E/AndroidRuntime(819): Caused by: java.lang.ClassNotFoundException: com.example.testamish.MainActivity
10-17 17:07:23.445: E/AndroidRuntime(819): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
10-17 17:07:23.445: E/AndroidRuntime(819): ... 11 more
Thanks for your help!
Solution
Remove this from you Manifest (from the original one!):
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And add this four line to the Activity, you want to start on launch:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Details
In Android, the data&actions between activities is driven by Intents. When you want to launch an app, it's kind an action between the Launcher app, and your app. It's also an Intent, when you start the Gallery, to choose an image for Facebook, or to start the Twitter app, to share something.
You can define in the Manifest.xml, for each Activity of your app, to which Intents to catch. You defined a MainActivity in your Manifest, and set to catch the android.intent.action.MAIN and android.intent.category.LAUNCHER intents. These two Intents responds, to start the app from the Launcher.
So the emulator was finding for your MainActivity, 'cause it read from you Manifest, to start that. But cannot found it, so throw an exception.
I did all steps to show Google maps in android.
I have downloaded the newest version of Google play services , but still I have the below exceptions :
07-18 05:25:36.319: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.389: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.389: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.489: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.529: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.559: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.629: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.709: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.769: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.949: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:36.989: W/GooglePlayServicesUtil(2054): Google Play services is missing.
07-18 05:25:40.239: I/Choreographer(2054): Skipped 494 frames! The application may be doing too much work on its main thread.
07-18 05:25:44.689: D/gralloc_goldfish(2054): Emulator without GPU emulation detected.
07-18 05:25:55.930: D/AndroidRuntime(2054): Shutting down VM
07-18 05:25:55.930: W/dalvikvm(2054): threadid=1: thread exiting with uncaught exception (group=0xb1f58648)
07-18 05:25:56.010: E/AndroidRuntime(2054): FATAL EXCEPTION: main
07-18 05:25:56.010: E/AndroidRuntime(2054): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending }
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.Activity.startActivityForResult(Activity.java:3390)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.Activity.startActivityForResult(Activity.java:3351)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.Activity.startActivity(Activity.java:3587)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.Activity.startActivity(Activity.java:3555)
07-18 05:25:56.010: E/AndroidRuntime(2054): at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.view.View.performClick(View.java:4240)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.view.View$PerformClick.run(View.java:17721)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.os.Handler.handleCallback(Handler.java:730)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.os.Handler.dispatchMessage(Handler.java:92)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.os.Looper.loop(Looper.java:137)
07-18 05:25:56.010: E/AndroidRuntime(2054): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-18 05:25:56.010: E/AndroidRuntime(2054): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 05:25:56.010: E/AndroidRuntime(2054): at java.lang.reflect.Method.invoke(Method.java:525)
07-18 05:25:56.010: E/AndroidRuntime(2054): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-18 05:25:56.010: E/AndroidRuntime(2054): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-18 05:25:56.010: E/AndroidRuntime(2054): at dalvik.system.NativeStart.main(Native Method)
07-18 05:26:02.570: I/Process(2054): Sending signal. PID: 2054 SIG: 9
this is the manifest of my app i have added permisions and the api key:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tunivote"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<permission android:name="com.example.tunivote.MAPS_RECEIVE" android:protectionLevel="signature"></permission>
<uses-permission android:name="com.example.tunivote.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.example.tunivote.providres.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="authentification"></activity>
</application>
</manifest>
Once check your emulator type, Whether it is Android or Google emulator. Please make sure your running on Google API Emulator.
Updated Program does what it should now. Thanks alot everyone!
There is this program im writing. Its supposed to show an imagebutton, when its pushed the programm should call a specific phone number. Eclipse doesnt return any errors. But when i run it on the emulator or my phone it quits without any explanation other than unfortunately srshelper (<- the prgram name) has stopped.
Here is the main java-class:
package com.example.srshelper;
import com.example.srshelper.R;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
ImageButton froschButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
froschButton = (ImageButton) findViewById(R.id.ibFrosch);
froschButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+"023588778600"));
startActivity(callIntent);
}
});
}
#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;
}
heres the 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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageButton
android:id="#+id/ibFrosch"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/frosch"
/>
</RelativeLayout>
the picture "frosch" lies in the drawable folder.
HALP! ;)
hey, thanks for the quick response. The logcat reports a missing file:
06-18 21:30:29.005: E/Trace(805): error opening trace file: No such file or directory (2)
06-18 21:30:29.105: W/ActivityThread(805): Application com.example.srshelper is waiting for the debugger on port 8100...
06-18 21:30:29.215: I/System.out(805): Sending WAIT chunk
06-18 21:30:29.435: I/dalvikvm(805): Debugger is active
06-18 21:30:29.635: I/System.out(805): Debugger has connected
06-18 21:30:29.635: I/System.out(805): waiting for debugger to settle...
06-18 21:30:29.845: I/System.out(805): waiting for debugger to settle...
06-18 21:30:30.045: I/System.out(805): waiting for debugger to settle...
06-18 21:30:30.255: I/System.out(805): waiting for debugger to settle...
06-18 21:30:30.455: I/System.out(805): waiting for debugger to settle...
06-18 21:30:30.655: I/System.out(805): waiting for debugger to settle...
06-18 21:30:30.855: I/System.out(805): waiting for debugger to settle...
06-18 21:30:31.065: I/System.out(805): waiting for debugger to settle...
06-18 21:30:31.265: I/System.out(805): waiting for debugger to settle...
06-18 21:30:31.465: I/System.out(805): waiting for debugger to settle...
06-18 21:30:31.675: I/System.out(805): debugger has settled (1431)
considering the permission, just doublecheked that ones again :D but it seems to be setup correcty. Heres the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.srshelper"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.srshelper.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>
Allright, some more research led me to a mysterious permission:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
After including that, the missing file error doesnt show up anymore, instead it reports some other errors. Going to look into them now :D.
06-19 09:25:31.903: I/Process(864): Sending signal. PID: 864 SIG: 9
06-19 09:35:22.192: D/AndroidRuntime(964): Shutting down VM
06-19 09:35:22.192: W/dalvikvm(964): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-19 09:35:22.212: E/AndroidRuntime(964): FATAL EXCEPTION: main
06-19 09:35:22.212: E/AndroidRuntime(964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.srshelper/com.example.srshelper.MainActivity}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.os.Handler.dispatchMessage(Handler.java:99)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.os.Looper.loop(Looper.java:137)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-19 09:35:22.212: E/AndroidRuntime(964): at java.lang.reflect.Method.invokeNative(Native Method)
06-19 09:35:22.212: E/AndroidRuntime(964): at java.lang.reflect.Method.invoke(Method.java:511)
06-19 09:35:22.212: E/AndroidRuntime(964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-19 09:35:22.212: E/AndroidRuntime(964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-19 09:35:22.212: E/AndroidRuntime(964): at dalvik.system.NativeStart.main(Native Method)
06-19 09:35:22.212: E/AndroidRuntime(964): Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
06-19 09:35:22.212: E/AndroidRuntime(964): at com.example.srshelper.MainActivity.onCreate(MainActivity.java:22)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.Activity.performCreate(Activity.java:5104)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-19 09:35:22.212: E/AndroidRuntime(964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-19 09:35:22.212: E/AndroidRuntime(964): ... 11 more
My initial guess is that you're missing the permission for making calls in your AndroidManifest
Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
ImageButton is not a Button. Your froschButton type is not consistent between code and layout.
When i Try to run my app from both simulator and phys device it crashes, heres the log
I have phonegap 1.3.0 :)
01-12 14:13:51.742: W/dalvikvm(344): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-12 14:13:51.791: E/AndroidRuntime(344): FATAL EXCEPTION: main
01-12 14:13:51.791: E/AndroidRuntime(344): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.philipslighting.roadlight/com.philipslighting.roadlight.PhilipsRoadlightFinalActivity}: java.lang.ClassNotFoundException: com.philipslighting.roadlight.PhilipsRoadlightFinalActivity in loader dalvik.system.PathClassLoader[/data/app/com.philipslighting.roadlight-1.apk]
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.os.Handler.dispatchMessage(Handler.java:99)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.os.Looper.loop(Looper.java:123)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-12 14:13:51.791: E/AndroidRuntime(344): at java.lang.reflect.Method.invokeNative(Native Method)
01-12 14:13:51.791: E/AndroidRuntime(344): at java.lang.reflect.Method.invoke(Method.java:507)
01-12 14:13:51.791: E/AndroidRuntime(344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-12 14:13:51.791: E/AndroidRuntime(344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-12 14:13:51.791: E/AndroidRuntime(344): at dalvik.system.NativeStart.main(Native Method)
01-12 14:13:51.791: E/AndroidRuntime(344): Caused by: java.lang.ClassNotFoundException: com.philipslighting.roadlight.PhilipsRoadlightFinalActivity in loader dalvik.system.PathClassLoader[/data/app/com.philipslighting.roadlight-1.apk]
01-12 14:13:51.791: E/AndroidRuntime(344): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-12 14:13:51.791: E/AndroidRuntime(344): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-12 14:13:51.791: E/AndroidRuntime(344): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-12 14:13:51.791: E/AndroidRuntime(344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
01-12 14:13:51.791: E/AndroidRuntime(344): ... 11 more
01-12 14:13:51.821: W/ActivityManager(61): Force finishing activity com.philipslighting.roadlight/.PhilipsRoadlightFinalActivity
01-12 14:13:52.341: W/ActivityManager(61): Activity pause timeout for HistoryRecord{4053ec18 com.philipslighting.roadlight/.PhilipsRoadlightFinalActivity}
01-12 14:13:53.151: I/Process(328): Sending signal. PID: 328 SIG: 9
01-12 14:13:53.181: I/ActivityManager(61): Process com.roadlight.philips (pid 328) has died.
01-12 14:13:54.331: I/Process(344): Sending signal. PID: 344 SIG: 9
01-12 14:13:54.371: W/InputManagerService(61): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#405c2d80
01-12 14:13:54.621: I/ActivityManager(61): Process com.philipslighting.roadlight (pid 344) has died.
here is my android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.philipslighting.roadlight"
android:versionCode="4"
android:versionName="1.2" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name">
<activity
android:label="#string/app_name"
android:name=".activities.MainActivity"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Were in the activity tag would you you import the phone gap activity?
Thanks in advance !
It you have used this tutorial http://phonegap.com/start#android
then to fix java.lang.ClassNotFoundException as above you need to check the box next to cordova-XXX.jar in the "Order and Export" tab then you add a dependency for cordova-XXX.jar in Libraries tab at "Configure Build Path".
And of course mainclass's name must be correct at android:name="<main class name>".
I was following the phonegap droid getting started guide
In my case, I had created a folder called lib instead of libs. A symptom of this was that I had to manually add the jar to the build path. I removed the jar from the build path, renamed the lib folder to libs and things started working immediately.
In activity you import the file for PhoneGap please check it.
and see the index.html file in your folder.
I think just follow this path :
http://phonegap.com/start#android
See, video you will find solution for this.
<activity
android:label="#string/app_name"
android:name=".activities.MainActivity"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
you should mention with package name along with main class name in 'activity' tag,look at below example:
android:name="com.philipslighting.roadlight.MainActivity"
<activity
android:label="#string/app_name"
android:name="yourPACKAGEname.MainActivity"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
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.