p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Android Application Development (http://p2p.wrox.com/forumdisplay.php?f=631)
-   -   activity error (http://p2p.wrox.com/showthread.php?t=86121)

droidus December 21st, 2011 06:58 PM

activity error
 
I am trying out the first exercise, but get this error:
Code:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3470), pid=4336, tid=2528
#  Error: ShouldNotReachHere()
#
# JRE version: 7.0_01-b08
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.1-b02 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\myUsername\workspace\Android\hs_err_pid4336.log
#
# If you would like to submit a bug report, please visit:
#  http://bugreport.sun.com/bugreport/crash.jsp
#


Cliff2310 December 21st, 2011 09:08 PM

Hi droidus
The java errors are hard to figure out. Post your code and maybe someone will spot your error.
Cliff

droidus December 22nd, 2011 01:51 PM

http://www.mediafire.com/?w1zchor9rebs175
http://www.mediafire.com/?f0a59f4pqlcf99u
http://www.mediafire.com/?ppqc6uhb3k4kps6

Cliff2310 December 22nd, 2011 09:09 PM

1. in the AndroidManifest.xml file change android:name to .MainActivity.
android:name=".MainActivity"
You may have done this, but you did not sent the manifest file.


2. Line 39 in MainActivity needs the name of the activity you are trying to start.
change
Intent i = new Intent("com.Android");

to
Intent i = new Intent("com.Android.ACTIVITY2");

Now it still can not find activity2. I do not know why.
The error message is:
12-22 18:56:53.706: E/AndroidRuntime(829): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.Android.ACTIVITY2 (has extras) }
Maybe someone else will know why.

It may be that your naming convention (com.Android and not com.Android.Activities).

3. General observation.
It appears you downloaded the code and just modified it. You should type in the code, yes I know its a pain, but that is how you learn.

Hope this helps some
Cliff

Cliff2310 December 22nd, 2011 09:24 PM

it works
 
The problem is in the manifest file. You need to add the following:
Code:

        // new activity 2
        <activity
            android:label="Activity 2"
            android:name ="Activity2"
        >
            <intent-filter >
                <action  android:name="com.Android.ACTIVITY2" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity

after the end of the first activity and before the </application>.
around line 20.
Cliff

droidus December 23rd, 2011 12:16 PM

thanks for the advice. i updated my code to show what it now looks like. still doesn't seem to run, after making the changes.

here are my files:

http://www.mediafire.com/?elh54lzfwizk2sm
http://www.mediafire.com/?bh7gg4nyj9rho0x
http://www.mediafire.com/?w7xwlx5q0fii3kz
http://www.mediafire.com/?zity55s004t626t

i get this error still:
Code:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3470), pid=6132, tid=5532
#  Error: ShouldNotReachHere()
#
# JRE version: 7.0_01-b08
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.1-b02 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows


Cliff2310 December 23rd, 2011 07:54 PM

Hi droidus
First line 39 of MainActivity should be:
Intent i = new Intent("com.Android.ACTIVITY2");
Activity should be in caps.
Also my Eclipse complains about the @Override in activity 2 & 3 at line 39 in 2
and line 23 in 3. This is just before the 'public void onClick(View view)' line.
They should be removed if eclipse says there is an error.
Other than that it runs.
It would seem that you have an error in your eclipse set up. Did you follow the instructions in the book when you set it up? None of the errors I get look anything like what you have posted.
If you still have a problem, tell us exactly what you are doing. What you have highlighted and how you start the program.
What I do is select the package name or MainActivity in the package explorer and press the 'run' button or the 'debug' button.
Do Not select the manifest or anything in layout.

Hope this helps
Cliff

droidus December 24th, 2011 01:12 PM

alrighty, thanks for your help! will have to play around with the code some.

just going back to some previous posts, what code should i manually type out? i noticed that the code for the exercises is not in the book. do i just download the code, and manually write that out?

also, when running the downloaded programs, i am not sure how to run them. i use eclipse. i see the .classpath, .project, AndroidManifest.xml, etc., but not any of the other ones, such as layout.activity2, or any of the src files. is there a simple way to import the whole project?

Cliff2310 December 24th, 2011 07:53 PM

Hi droidus

just going back to some previous posts, what code should i manually type out? i noticed that the code for the exercises is not in the book. do i just download the code, and manually write that out?
You should write out all the code, this is how you learn. Also Lee usually starts with one function and then adds to it. The code from the web site is just the final form. You will miss out if you don't do them in order. I use the the downloaded code to compare to my code when I have a problem.
Basically you should follow the instructions in the book, that's why you paid good money for it.

also, when running the downloaded programs, i am not sure how to run them. i use eclipse. i see the .classpath, .project, AndroidManifest.xml, etc., but not any of the other ones, such as layout.activity2, or any of the src files. is there a simple way to import the whole project?
If you do want to try the downloaded code you must copy everything in to the project you created for it. I have not figured how to import code as a project. If anyone knows, please tell me.
Cliff

droidus December 25th, 2011 08:40 PM

so basically you write the code yourself, and check it against what they have? i thought that they would have taught you from the bottom up how to build android applications.


All times are GMT -4. The time now is 10:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.