java.lang.NoClassDefFoundError: com.parse.ParseCrashReporting - android

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

Related

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

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.

Unable to instantiate activity error? how to solve it?

I made an App. and since I just wanted to test some functions before adding them to the App,
I decided to copy my project into a new Project. When I tried to run the new project, the app crashes and the log-cat output is as follows.
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidbook.MP"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true">
<activity
android:name=".MPActivity"
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="AddLocationActivity"></activity>
<activity android:name="MPData"></activity>
<activity android:name="MyLocations"></activity>
<activity android:name="MPInfo"></activity>
<activity android:name="Navigation"></activity>
</application>
LogCat:
05-21 15:30:03.710: E/AndroidRuntime(11294): FATAL EXCEPTION: main
05-21 15:30:03.710: E/AndroidRuntime(11294): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.androidbook.MP/com.androidbook.MP.MPActivity}:
java.lang.ClassNotFoundException: com.androidbook.MP.MPActivity in loader
dalvik.system.PathClassLoader[/data/app/com.androidbook.MP-1.apk]
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.os.Looper.loop(Looper.java:130)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.ActivityThread.main(ActivityThread.java:3691)
05-21 15:30:03.710: E/AndroidRuntime(11294): at java.lang.reflect.Method.invokeNative(Native Method)
05-21 15:30:03.710: E/AndroidRuntime(11294): at java.lang.reflect.Method.invoke(Method.java:507)
05-21 15:30:03.710: E/AndroidRuntime(11294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
05-21 15:30:03.710: E/AndroidRuntime(11294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
05-21 15:30:03.710: E/AndroidRuntime(11294): at dalvik.system.NativeStart.main(Native Method)
05-21 15:30:03.710: E/AndroidRuntime(11294): Caused by: java.lang.ClassNotFoundException: com.androidbook.MP.MPActivity in loader dalvik.system.PathClassLoader[/data/app/com.androidbook.MP-1.apk]
05-21 15:30:03.710: E/AndroidRuntime(11294): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-21 15:30:03.710: E/AndroidRuntime(11294): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-21 15:30:03.710: E/AndroidRuntime(11294): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-21 15:30:03.710: E/AndroidRuntime(11294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
05-21 15:30:03.710: E/AndroidRuntime(11294): ... 11 more
Check your Manifest file, if the activity is to be declared.
for Ex:
<application>
<activity android:name=".MyActivity" 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>
Look through all the files in your new project and make sure they aren't referencing classes from the old project.
I think I found the solution, i should have checked that, the package name of the new project is included in the manifest file as for an example
"package="com.androidbook.MPTest" ..
my mistake is the i used the package name of the old project as a package name of the new project.

Android ClassNotFoundException

I have problem with my app, everything was working fine yesterday but today I updated sdk and now when I'm trying to run my app I'm getting errors like this
05-21 00:14:19.285: W/dalvikvm(7061): Unable to resolve superclass of Lcom/lpp/towndefence/MainMenuActivity; (122)
05-21 00:14:19.285: W/dalvikvm(7061): Link of class 'Lcom/lpp/towndefence/MainMenuActivity;' failed
05-21 00:14:19.285: D/AndroidRuntime(7061): Shutting down VM
05-21 00:14:19.285: W/dalvikvm(7061): threadid=1: thread exiting with uncaught exception (group=0x40018560)
05-21 00:14:19.345: E/AndroidRuntime(7061): FATAL EXCEPTION: main
05-21 00:14:19.345: E/AndroidRuntime(7061): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lpp.towndefence/com.lpp.towndefence.MainMenuActivity}: java.lang.ClassNotFoundException: com.lpp.towndefence.MainMenuActivity in loader dalvik.system.PathClassLoader[/data/app/com.lpp.towndefence-1.apk]
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1679)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1783)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:938)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.os.Looper.loop(Looper.java:130)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.ActivityThread.main(ActivityThread.java:3837)
05-21 00:14:19.345: E/AndroidRuntime(7061): at java.lang.reflect.Method.invokeNative(Native Method)
05-21 00:14:19.345: E/AndroidRuntime(7061): at java.lang.reflect.Method.invoke(Method.java:507)
05-21 00:14:19.345: E/AndroidRuntime(7061): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
05-21 00:14:19.345: E/AndroidRuntime(7061): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
05-21 00:14:19.345: E/AndroidRuntime(7061): at dalvik.system.NativeStart.main(Native Method)
05-21 00:14:19.345: E/AndroidRuntime(7061): Caused by: java.lang.ClassNotFoundException: com.lpp.towndefence.MainMenuActivity in loader dalvik.system.PathClassLoader[/data/app/com.lpp.towndefence-1.apk]
05-21 00:14:19.345: E/AndroidRuntime(7061): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-21 00:14:19.345: E/AndroidRuntime(7061): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-21 00:14:19.345: E/AndroidRuntime(7061): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-21 00:14:19.345: E/AndroidRuntime(7061): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1671)
05-21 00:14:19.345: E/AndroidRuntime(7061): ... 11 more
my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lpp.towndefence"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".MainMenuActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TownDefenseActivity">
</activity>
</application>
</manifest>
I cleaned project, fixed project properties but it didn't help.
Like #Barak said: jar files goes in libs directory. But make sure that libraries are checked at "project properties" -> "java build path" -> "order and export" too.

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 :-)

Categories

Resources