Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Horrible noob needs big help!

Horrible noob needs big help!

Put your problem here if it does not fit any of the other categories.

Horrible noob needs big help!

Postby MagicMojo » Thu Jan 20, 2011 4:44 pm

Hi,

I hate to bother you all with such a big question, but I'm having lots of trouble with this project, many errors in my code, which I'm at a loss to solve.

This is a really simple app where the user presses a button, then a timestamp gets recorded and I haven't gotten round to making te menu-entry ti let the user read the times.


My GUI contains only one button with Id Id @+id/Button01, and that's the Id that's used in the code. I'm totally new to Java (not to C++. C# though) and to Android. I thought I'd start simple to get going. Babysteps: I ditched the LinkedList + ListIterator which I first wanted to use to record multiple entries. I thought not going for an SQL-db as I planned at first, would be sufficiently babysteppy, but II'm having trouble enough as it is. I'm a worse noob than I thought - damn :cry:. Any pointers would be very much appreciated !

BTW this is using Helios (3.6 SR1).

Here are the errors:

Code: Select all
Description   Resource   Path   Location   Type
Cannot cast from View to Button   Button.java   /MagicButton/src/com/magicmojo/button   line 24   Java Problem
Cannot cast from View to Button   Button.java   /MagicButton/src/com/magicmojo/button   line 24   Java Problem
Syntax error on token "}", { expected   Button.java   /MagicButton/src/com/magicmojo/button   line 16   Java Problem
Syntax error on token "}", { expected after this token   Button.java   /MagicButton/src/com/magicmojo/button   line 28   Java Problem
Syntax error on token "}", delete this token   Button.java   /MagicButton/src/com/magicmojo/button   line 33   Java Problem
Syntax error, insert ";" to complete Statement   Button.java   /MagicButton/src/com/magicmojo/button   line 32   Java Problem
Syntax error, insert ")" to complete Expression   Button.java   /MagicButton/src/com/magicmojo/button   line 32   Java Problem
Syntax error, insert "}" to complete ClassBody   Button.java   /MagicButton/src/com/magicmojo/button   line 32   Java Problem


Here's the code:

Code: Select all
package com.magicmojo.button;

import java.util.Date;
import android.view.View.OnClickListener;
import java.util.LinkedList;

import android.app.Activity;
import android.os.Bundle;

public class Button extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
   
    /*LinkedList tl = new LinkedList(<string>);
      //Doesn't work! No list then, only register a single point in time
    ListIterator li = tl.listIterator(tl.size());*/

    setContentView(R.layout.main);
    Button button = (Button) findViewById(R.id.Button01);
    button.setOnClickListener(new OnClickListener() {
       Date now = new Date();
       //String dstring = DateFormat.getDateInstance().format(myDate);
       String dstring;{}   // = new String(){
       dstring = DateFormat.getDateInstance().format(myDate);}

       //tl.add (dString)
    ;}}
}
MagicMojo
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Nov 27, 2010 9:40 am

Top

Re: Horrible noob needs big help!

Postby vengeance_mj » Thu Jan 20, 2011 8:49 pm

1st error rename ur class from Button to something like MagicButton. Button is a class within the Android SDK so you cannot have the same class name as the classes already defined in the Android SDK.

Here's the edited file. I suggest you use a good IDE for coding like Eclipse. Toggle the Auto import features. It will also give u some hints as to what is wrong with the code and missing brackets as well

Code: Select all

import java.util.Date;

import android.app.Activity;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MagicButton extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      /*
       * LinkedList tl = new LinkedList(<string>); //Doesn't work! No list
       * then, only register a single point in time ListIterator li =
       * tl.listIterator(tl.size());
       */

      Button button = (Button) findViewById(R.id.Button01);
      button.setOnClickListener(new OnClickListener() {
         public void onClick(View aView) {
            Date now = new Date();
            // String dstring = DateFormat.getDateInstance().format(myDate);
            String dstring; // = new String(){
            dstring = DateFormat.getDateInstance().format(myDate);

            // tl.add (dString)

         }
      });
   }
}
vengeance_mj
Senior Developer
Senior Developer
 
Posts: 174
Joined: Thu Oct 29, 2009 2:32 am

Re: Horrible noob needs big help!

Postby MagicMojo » Sat Jan 22, 2011 2:15 pm

Hi, thanks for the help (and sorry for the late reply), the Button/MagicButton-thing was too obvious... Sorry!
But I keep getting these odd errors:

The method getDateInstance() is undefined for the type DateFormat

Huh? I got that from the Oracle-website http://download.oracle.com/javase/1.4.2/docs/api/java/text/DateFormat.html and I do believe I have the latest Java SDK (v6)

And yes, I AM using Eclipse (3.6.1, Helios), but it can be confusing. Basically, this is my first time using Java, Eclipse and also Android. I have my mouth full right now.
MagicMojo
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Nov 27, 2010 9:40 am

Re: Horrible noob needs big help!

Postby Jems » Sat Jan 22, 2011 3:17 pm

You are using the Android DateFormat class, not the standard Java one. Sometimes even the standard java classes that come with Android platform (like java.util.Date in your app) can be a bit different.
The reference you should use is
http://developer.android.com/reference/ ... ormat.html
You can see that class has no getDateInstance() method.

You should probably be importing java.text.DateFormat instead, which does match with what you are expecting.
http://developer.android.com/reference/ ... ormat.html
Jems
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Thu Dec 09, 2010 7:42 pm

Re: Horrible noob needs big help!

Postby MagicMojo » Sun Jan 23, 2011 1:47 pm

Thank you vrey much, I have: Progress!
In fact, I have it twice: it now compiles and gets sent to the emulator, where it force closes, and next progress-point: I now have an icon (yeehaw, my app is now complete! It has an icon)
I'm trying to debug, but my book tells me to include a certain few lines of code (done, I now have
"import android.util.Log;" and in onCreate:
Code: Select all
Log.e("MagicButton Debugging", "My 1st Android logger");
, and then I'm supposed to open the LogCat pane in Eclipse,
which I cannnot find in Helios. not even in the help.
I do sometimes see messages appear on the console (not every time I start the program, though). I sent the logcat-output to a txtfile, but I ended up with a txtfile of 62.732b and no apparent formatting (as in line breaks; obvious, since it's console-output), no apparent time stamping. I do notice this line:
Code: Select all
Start proc com.magicmojo.button for activity com.magicmojo.button/.Button: pid=220 uid=10025 gids={}
immediately followed by
Code: Select all
D/AndroidRuntime(  189): Shutting down VM D/dalvikvm(  189): DestroyJavaVM waiting for non-daemon threads to exit D/dalvikvm(  189): DestroyJavaVM shutting VM down D/dalvikvm(  189):

So in short: I've removed all warnings and errors, (by commenting out lines that weren't doing much anyway, and by commenting out the associated imports).
Here's the result of my latest attempt: I created & started the new AVD, started ADB LogCat > logcat.txt, and ended up with this output:
(note thatIonly copied in the bit starting at the first mention of the word magic, until the end of the file (where I cancelled the amulator) I find it odd that it starts by removing my package, even if it's never been installed before (not in this emu anyway)
Code: Select all
Removing non-system package:com.magicmojo.button D/PackageManager(   65): Removing package com.magicmojo.button D/PackageManager(   65):   Activities: com.magicmojo.button.Button D/PackageManager(   65): Scanning package com.magicmojo.button I/PackageManager(   65): /data/app/vmdl49081.tmp changed; unpacking D/installd(   32): DexInv: --- BEGIN '/data/app/vmdl49081.tmp' --- D/dalvikvm(  229): DexOpt: load 36ms, verify 43ms, opt 3ms D/installd(   32): DexInv: --- END '/data/app/vmdl49081.tmp' (success) --- D/PackageManager(   65):   Activities: com.magicmojo.button.Button D/ActivityManager(   65): Uninstalling process com.magicmojo.button I/installd(   32): move /data/dalvik-cache/data@app@vmdl49081.tmp@classes.dex -> /data/dalvik-cache/data@app@com.magicmojo.button.apk@classes.dex D/PackageManager(   65): New package installed in /data/app/com.magicmojo.button.apk D/AndroidRuntime(  223): Shutting down VM D/dalvikvm(  223): DestroyJavaVM waiting for non-daemon threads to exit D/dalvikvm(  223): DestroyJavaVM shutting VM down D/dalvikvm(  223): HeapWorker thread shutting down D/dalvikvm(  223): HeapWorker thread has shut down D/jdwp    (  223): JDWP shutting down net... I/dalvikvm(  223): Debugger has detached; object registry had 1 entries D/dalvikvm(  223): VM cleaning up D/ActivityManager(   65): Uninstalling process com.magicmojo.button E/AndroidRuntime(  223): ERROR: thread attach failed D/dalvikvm(  223): LinearAlloc 0x0 used 623916 of 5242880 (11%) W/ResourceType(   65): Resources don't contain package for resource number 0x7f0700e5 W/ResourceType(   65): Resources don't contain package for resource number 0x7f020031 W/ResourceType(   65): Resources don't contain package for resource number 0x7f020030 W/ResourceType(   65): Resources don't contain package for resource number 0x7f050000 W/ResourceType(   65): Resources don't contain package for resource number 0x7f060000 W/ResourceType(   65): Resources don't contain package for resource number 0x7f060001 I/ActivityManager(   65): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=236 uid=10012 gids={} D/dalvikvm(  112): GC freed 1719 objects / 85248 bytes in 280ms D/ddm-heap(  236): Got feature list request D/dalvikvm(   30): GC freed 277 objects / 10624 bytes in 463ms D/dalvikvm(   65): GC freed 7681 objects / 475056 bytes in 559ms W/ResourceType(   65): Resources don't contain package for resource number 0x7f0700e5 W/ResourceType(   65): Resources don't contain package for resource number 0x7f020031 W/ResourceType(   65): Resources don't contain package for resource number 0x7f020030 W/ResourceType(   65): Resources don't contain package for resource number 0x7f050000 W/ResourceType(   65): Resources don't contain package for resource number 0x7f060000 W/ResourceType(   65): Resources don't contain package for resource number 0x7f060001 D/dalvikvm(   30): GC freed 45 objects / 2016 bytes in 403ms D/dalvikvm(   30): GC freed 2 objects / 48 bytes in 297ms D/AndroidRuntime(  235):  D/AndroidRuntime(  235): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< D/AndroidRuntime(  235): CheckJNI is ON D/AndroidRuntime(  235): --- registering native functions --- D/ddm-heap(  235): Got feature list request I/ActivityManager(   65): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.magicmojo.button/.Button } I/ActivityManager(   65): Start proc com.magicmojo.button for activity com.magicmojo.button/.Button: pid=249 uid=10025 gids={} D/AndroidRuntime(  235): Shutting down VM D/dalvikvm(  235): DestroyJavaVM waiting for non-daemon threads to exit D/dalvikvm(  235): DestroyJavaVM shutting VM down D/dalvikvm(  235): HeapWorker thread shutting down D/dalvikvm(  235): HeapWorker thread has shut down D/jdwp    (  235): JDWP shutting down net... I/dalvikvm(  235): Debugger has detached; object registry had 1 entries D/dalvikvm(  235): VM cleaning up E/AndroidRuntime(  235): ERROR: thread attach failed D/dalvikvm(  235): LinearAlloc 0x0 used 639500 of 5242880 (12%) D/ddm-heap(  249): Got feature list request D/AndroidRuntime(  249): Shutting down VM W/dalvikvm(  249): threadid=3: thread exiting with uncaught exception (group=0x4001b188) E/AndroidRuntime(  249): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime(  249): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.magicmojo.button/com.magicmojo.button.Button}: java.lang.ClassNotFoundException: com.magicmojo.button.Button in loader dalvik.system.PathClassLoader@43d0b8a8 E/AndroidRuntime(  249):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) E/AndroidRuntime(  249):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) E/AndroidRuntime(  249):    at android.app.ActivityThread.access$2200(ActivityThread.java:119) E/AndroidRuntime(  249):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) E/AndroidRuntime(  249):    at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(  249):    at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime(  249):    at android.app.ActivityThread.main(ActivityThread.java:4363) E/AndroidRuntime(  249):    at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(  249):    at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime(  249):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) E/AndroidRuntime(  249):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) E/AndroidRuntime(  249):    at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime(  249): Caused by: java.lang.ClassNotFoundException: com.magicmojo.button.Button in loader dalvik.system.PathClassLoader@43d0b8a8 E/AndroidRuntime(  249):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) E/AndroidRuntime(  249):    at java.lang.ClassLoader.loadClass(ClassLoader.java:573) E/AndroidRuntime(  249):    at java.lang.ClassLoader.loadClass(ClassLoader.java:532) E/AndroidRuntime(  249):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021) E/AndroidRuntime(  249):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409) E/AndroidRuntime(  249):    ... 11 more I/Process (   65): Sending signal. PID: 249 SIG: 3 I/dalvikvm(  249): threadid=7: reacting to signal 3 E/dalvikvm(  249): Unable to open stack trace file '/data/anr/traces.txt': Permission denied I/ARMAssembler(   65): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x375028:0x3750e4] in 1007927 ns W/ActivityManager(   65): Launch timeout has expired, giving up wake lock! W/ActivityManager(   65): Activity idle timeout for HistoryRecord{43c44100 com.magicmojo.button/.Button} D/KeyguardViewMediator(   65): pokeWakelock(5000) D/KeyguardViewMediator(   65): pokeWakelock(5000) W/WindowManager(   65): No window to dispatch pointer action 1 I/ARMAssembler(   65): generated scanline__00000077:03545404_00000A04_00000000 [ 29 ipp] (51 ins) at [0x37c710:0x37c7dc] in 773202 ns I/ARMAssembler(   65): generated scanline__00000177:03515104_00001A01_00000000 [ 73 ipp] (98 ins) at [0x37c7e0:0x37c968] in 871583 ns I/Process (  249): Sending signal. PID: 249 SIG: 9 I/ActivityManager(   65): Process com.magicmojo.button (pid 249) has died. I/UsageStats(   65): Unexpected resume of com.android.launcher while already resumed in com.magicmojo.button I/ARMAssembler(   65): generated scanline__00000177:03515104_00000001_00000000 [ 73 ipp] (95 ins) at [0x37cd30:0x37ceac] in 1201888 ns I/ARMAssembler(   65): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x37ceb0:0x37d078] in 925172 ns I/ActivityManager(   65): Displayed activity com.android.launcher/.Launcher: 100210 ms (total 100210 ms)
MagicMojo
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Nov 27, 2010 9:40 am

Re: Horrible noob needs big help!

Postby jonbonazza » Sun Jan 23, 2011 8:34 pm

In the tools directory where you installed your Android SDK, there is a file called DDMS. Use that.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 7 guests