how to define in manifest file which is activity of another [closed] - android

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have designed Main class. From main I am calling another class named Menu that extends Activity, and from Menu class I am calling another activity class. But it's not working. What changes should be needed in manifest file?
Here the logcat
09-09 23:53:42.741: D/gralloc_goldfish(2105): Emulator without GPU emulation detected.
09-09 23:53:47.982: D/AndroidRuntime(2105): Shutting down VM
09-09 23:53:47.982: W/dalvikvm(2105): threadid=1: thread exiting with uncaught exception (group=0xb4e02288)
09-09 23:53:48.011: E/AndroidRuntime(2105): FATAL EXCEPTION: main
09-09 23:53:48.011: E/AndroidRuntime(2105): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.parse.starter/com.parse.starter.Placementmania}; have you declared this activity in your AndroidManifest.xml?
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.Activity.startActivityForResult(Activity.java:3351)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.Activity.startActivityForResult(Activity.java:3312)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.Activity.startActivity(Activity.java:3522)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.Activity.startActivity(Activity.java:3490)
09-09 23:53:48.011: E/AndroidRuntime(2105): at com.parse.starter.Mainmenu$1.onClick(Mainmenu.java:27)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.view.View.performClick(View.java:4084)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.view.View$PerformClick.run(View.java:16966)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.os.Handler.handleCallback(Handler.java:615)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.os.Handler.dispatchMessage(Handler.java:92)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.os.Looper.loop(Looper.java:137)
09-09 23:53:48.011: E/AndroidRuntime(2105): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-09 23:53:48.011: E/AndroidRuntime(2105): at java.lang.reflect.Method.invokeNative(Native Method)
09-09 23:53:48.011: E/AndroidRuntime(2105): at java.lang.reflect.Method.invoke(Method.java:511)
09-09 23:53:48.011: E/AndroidRuntime(2105): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-09 23:53:48.011: E/AndroidRuntime(2105): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-09 23:53:48.011: E/AndroidRuntime(2105): at dalvik.system.NativeStart.main(Native Method)
09-09 23:53:50.212: I/Process(2105): Sending signal. PID: 2105 SIG: 9

In your manifest, you'll see this code
<activity
android:name="com.example.yourappname.MainScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Basically copy and paste that and modify pasted one with the name and category for each of your classes like this:
<activity
android:name="com.example.audeoapp.OtherClass" >
<intent-filter>
<action android:name="android.intent.action.OTHERCLASS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.audeoapp.AnotherClass" >
<intent-filter>
<action android:name="android.intent.action.ANOTHERCLASS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Add this into your manifest
<activity
android:name="com.parse.starter.Placementmania"
android:label="#string/app_name"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

intent.action.main and intent.category.launcher tells that this activity is your main and launching activity which should get open when you launch your app..for other activities just put you activity name and label inside the new activity tag.

Related

java.lang.NoClassDefFoundError: com.parse.ParseCrashReporting

I am using sample code of parse for android ,but when try to run the code then it shows the error
java.lang.NoClassDefFoundError: com.parse.ParseCrashReporting
I have already enabled the library in project properties in java build path ,please help me to find out where the problem
public class ParseStarterProjectActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ParseAnalytics.trackAppOpenedInBackground(getIntent());
}
}
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
// Initialize Crash Reporting.
ParseCrashReporting.enable(this);
Parse.initialize(this, "*****************************", "*******************");
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
// Add your initialization code here
Parse.initialize(this);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// Optionally enable public read access.
// defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
}
}
and my logcat is
04-28 17:29:17.923: I/dalvikvm(12489): Could not find method com.parse.ParseCrashReporting.enable, referenced from method com.parse.starter.ParseApplication.onCreate
04-28 17:29:17.923: W/dalvikvm(12489): VFY: unable to resolve static method 10: Lcom/parse/ParseCrashReporting;.enable (Landroid/content/Context;)V
04-28 17:29:17.923: D/dalvikvm(12489): VFY: replacing opcode 0x71 at 0x0003
04-28 17:29:17.923: D/dalvikvm(12489): DexOpt: unable to opt direct call 0x0007 at 0x18 in Lcom/parse/starter/ParseApplication;.onCreate
04-28 17:29:17.923: D/AndroidRuntime(12489): Shutting down VM
04-28 17:29:17.923: W/dalvikvm(12489): threadid=1: thread exiting with uncaught exception (group=0x417f6da0)
04-28 17:29:17.923: E/AndroidRuntime(12489): FATAL EXCEPTION: main
04-28 17:29:17.923: E/AndroidRuntime(12489): Process: com.parse.starter, PID: 12489
04-28 17:29:17.923: E/AndroidRuntime(12489): java.lang.NoClassDefFoundError: com.parse.ParseCrashReporting
04-28 17:29:17.923: E/AndroidRuntime(12489): at com.parse.starter.ParseApplication.onCreate(ParseApplication.java:17)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4749)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.app.ActivityThread.access$1600(ActivityThread.java:172)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.os.Handler.dispatchMessage(Handler.java:102)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.os.Looper.loop(Looper.java:146)
04-28 17:29:17.923: E/AndroidRuntime(12489): at android.app.ActivityThread.main(ActivityThread.java:5653)
04-28 17:29:17.923: E/AndroidRuntime(12489): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 17:29:17.923: E/AndroidRuntime(12489): at java.lang.reflect.Method.invoke(Method.java:515)
04-28 17:29:17.923: E/AndroidRuntime(12489): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
04-28 17:29:17.923: E/AndroidRuntime(12489): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
04-28 17:29:17.923: E/AndroidRuntime(12489): at dalvik.system.NativeStart.main(Native Method)
manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.parse.starter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".ParseApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="#string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="#string/parse_client_key" />
<activity
android:name=".ParseStarterProjectActivity"
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>
maybe, the reason is why you are writing the same twice, I mean, you are using Parse.initialize twice...
You should to erase the second, because ParseCrashReporting must be before to initialize, but after, it is not necessary. Try it.
https://parse.com/apps/quickstart#parse_data/mobile/android/native/new

Starting an alarm manager application on reboot

Presently, I am working on app that sets the phone into the vibration mode or the ringer mode at the selected time. I have successfully implemented this using the alarmmanager in my application.
I want my app to remember all the pending intents when the phone is rebooted.
I found a sample code in the internet, but it seems to crash my app when the phone is rebooted. I don't know what's going wrong.
Here is alarmreciever.java
package ishan.khandelwal.vitsilentmode;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.widget.Toast;
public class AlarmReciever extends BroadcastReceiver
{
private AudioManager mAudioManager;
#Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
Intent serviceIntent = new Intent("ishan.khandelwal.vitsilentmode");
context.startService(serviceIntent);
}
mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
// Show the toast
Toast.makeText(context, "Vibration Mode", Toast.LENGTH_SHORT).show();
}
}
Android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ishan.khandelwal.vitsilentmode"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<!-- permission required to use Alarm Manager -->
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver
android:name=".receiver.StartMyServiceAtBootReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="ishan.khandelwal.vitsilentmode.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="ishan.khandelwal.vitsilentmode.GetSlots"
android:label="Select your slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.MorningSlots"
android:label="Select your morning slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.EveningSlots"
android:label="Select your evening slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.Labs"
android:label="Select your lab slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.About"
android:label="About"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.AlarmReciever"
android:label="AlarmReciever" >
</activity>
<!-- Register the Alarm Receiver -->
<receiver android:name=".AlarmReciever"/>
<activity
android:name="ishan.khandelwal.vitsilentmode.RingerMode"
android:label="RingerMode" >
</activity>
<!-- Register the Alarm Receiver -->
<receiver android:name=".RingerMode"/>
</application>
Logcat:
07-23 23:33:12.057: I/ActivityManager(858): Start proc com.android.providers.calendar for broadcast com.android.providers.calendar/.CalendarReceiver: pid=1116 uid=10023 gids={3003}
07-23 23:33:12.067: I/ActivityThread(1116): Pub com.android.calendar: com.android.providers.calendar.CalendarProvider2
07-23 23:33:12.087: I/SurfaceFlinger(858): Boot is finished (2041 ms)
07-23 23:33:12.128: I/ActivityManager(858): Start proc ishan.khandelwal.vitsilentmode for broadcast ishan.khandelwal.vitsilentmode/.receiver.StartMyServiceAtBootReceiver: pid=1127 uid=10031 gids={}
07-23 23:33:12.137: D/AndroidRuntime(1127): Shutting down VM
07-23 23:33:12.137: W/dalvikvm(1127): threadid=1: thread exiting with uncaught exception (group=0xb6fac4f0)
07-23 23:33:12.137: E/AndroidRuntime(1127): FATAL EXCEPTION: main
07-23 23:33:12.137: E/AndroidRuntime(1127): java.lang.RuntimeException: Unable to instantiate receiver ishan.khandelwal.vitsilentmode.receiver.StartMyServiceAtBootReceiver: java.lang.ClassNotFoundException: ishan.khandelwal.vitsilentmode.receiver.StartMyServiceAtBootReceiver in loader dalvik.system.PathClassLoader[/data/app/ishan.khandelwal.vitsilentmode-1.apk]
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1773)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.os.Looper.loop(Looper.java:130)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.reflect.Method.invoke(Method.java:507)
07-23 23:33:12.137: E/AndroidRuntime(1127): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-23 23:33:12.137: E/AndroidRuntime(1127): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-23 23:33:12.137: E/AndroidRuntime(1127): at dalvik.system.NativeStart.main(Native Method)
07-23 23:33:12.137: E/AndroidRuntime(1127): Caused by: java.lang.ClassNotFoundException: ishan.khandelwal.vitsilentmode.receiver.StartMyServiceAtBootReceiver in loader dalvik.system.PathClassLoader[/data/app/ishan.khandelwal.vitsilentmode-1.apk]
07-23 23:33:12.137: E/AndroidRuntime(1127): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1764)
07-23 23:33:12.137: E/AndroidRuntime(1127): ... 10 more
Thanks for the help in advance.
Ok, the problem is that you have specified in your AndroidManifest the wrong/a nonexistent receiver implementation. You specified this:
<receiver
android:name=".receiver.StartMyServiceAtBootReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
The problem is you have no class called StartMyServiceAtBootReceiver. What you I think you should have is something like this:
<receiver
android:name=".AlarmReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>

Android - exception when compiling and running the application

I am running a debug android application with eclipse and the simulator, and on a restarting of the app, I get this exception,
03-23 02:19:51.384: E/AndroidRuntime(605): FATAL EXCEPTION: main
03-23 02:19:51.384: E/AndroidRuntime(605): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.os.Looper.loop(Looper.java:137)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-23 02:19:51.384: E/AndroidRuntime(605): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 02:19:51.384: E/AndroidRuntime(605): at java.lang.reflect.Method.invoke(Method.java:511)
03-23 02:19:51.384: E/AndroidRuntime(605): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-23 02:19:51.384: E/AndroidRuntime(605): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-23 02:19:51.384: E/AndroidRuntime(605): at dalvik.system.NativeStart.main(Native Method)
03-23 02:19:51.384: E/AndroidRuntime(605): Caused by: java.lang.NullPointerException
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
03-23 02:19:51.384: E/AndroidRuntime(605): ... 11 more
But this doesn't really say where the error happened in my code. Any idea why this might be happening and how to prevent it?
and this is the entire manifest of the small application:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.problemio"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ProblemioActivity"
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=".AddProblemActivity"
android:label="#string/add_problem" />
<activity
android:name=".LoginActivity"
android:label="#string/login" />
<activity
android:name=".MyProblemsActivity"
android:label="#string/your_problems" />
<activity
android:name=".LogoutActivity"
android:label="#string/app_name" />
<activity
android:name=".CreateProfileActivity"
android:label="#string/create_account" />
<activity
android:name=".ProblemActivity"
android:label="#string/problem_page_header" />
<activity
android:name=".SuggestSolutionActivity"
android:label="#string/suggest_solution_header" />
<activity
android:name=".SuggestedSolutionActivity"
android:label="#string/suggested_solution_header" />
<activity
android:name=".ViewSolutionsActivity"
android:label="#string/view_solutions_header" />
<activity
android:name=".TopicActivity"
android:label="#string/topic_header" />
</application>
</manifest>
Thanks!
I also get this excepiton.
I am using Nexus S, and update to 4.0.3
I just ignore this exception.
The real solution to this problem is a folder permissions issue. Make sure you are operating in a folder that you can modify. I just fixed that same problem for my self by making sure I was in a folder with the right permissions.

My Android App Keeps Crashing

I've started to learn Android Development and I got this snippit off of google android development site, it keeps on crashing.
My specs are:
Android 4.0.3
API 15
Code:
package lewes.android.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
I get...
Unfortenualy, HelloAndroid is not responding.
Please help me!
MY MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloWorld"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
LogCat:
03-17 11:35:19.835: D/AndroidRuntime(562): Shutting down VM
03-17 11:35:19.835: W/dalvikvm(562): threadid=1: thread exiting with uncaught
exception (group=0x409c01f8)
03-17 11:35:19.914: E/AndroidRuntime(562): FATAL EXCEPTION: main
03-17 11:35:19.914: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{lewes.android.hello/lewes.android.hello.HelloWorld}:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.access$600(ActivityThread.java:123)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 11:35:19.914: E/AndroidRuntime(562): at android.os.Looper.loop(Looper.java:137)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.main(ActivityThread.java:4424)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invoke(Method.java:511)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 11:35:19.914: E/AndroidRuntime(562): at dalvik.system.NativeStart.main(Native
Method)
03-17 11:35:19.914: E/AndroidRuntime(562): Caused by:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-17 11:35:19.914: E/AndroidRuntime(562): ... 11 more
03-17 11:40:20.114: I/Process(562): Sending signal. PID: 562 SIG: 9
Delete one of the application sections from your manifest.
Keep the one where the activity corresponds to the name of your class.
make your manifest look exactly like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloAndroid"
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>
Change
<activity
android:name=".HelloAndroidActivity"
to
<activity
android:name=".HelloAndroid"
SDK does not mention about this. But as my experience, activity (this) can not be used inside onCreate(Bundle) to initialize new objects. To be used as a parameter for constructors, this is nothing within onCreate().
You can follow this hello world. It uses static xml layout.
Hope this helps you :-)

Phonegap app Crashes at Runtime

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>

Categories

Resources