Android and Arduino hello world tutorial: Null point exception error

Discussion in 'Android' started by Mariam, Mar 20, 2016.

  1. Mariam

    Mariam New Member

    Joined:
    Mar 20, 2016
    Messages:
    10
    Likes Received:
    1
    Hi,
    I have tried the Hello world tutorial to blink the LED using UDOO QUAD , the link is below
    http://www.udoo.org/tutorial/android-arduino-udoo-simple-hello-world-tutorial/
    The app shows a null pointer exception during runtime, points to the lines below

    if (buttonLED.isChecked()) {
    mAdkManager.writeSerial("1");
    } else {
    mAdkManager.writeSerial("0");
    }

    After uploading to UDOO, the app stops working when the toggle buton is clicked, and also the Arduino shows the message "No installed apps work with this USB accessory" when the OTG connection is disabled while trying to reconnect with arduino's SAM 3X8E.

    How can I solve this issue?

    Mariam
     
  2. xiamingliang

    xiamingliang New Member

    Joined:
    Mar 25, 2016
    Messages:
    4
    Likes Received:
    1
    check the log/java backtrace
    it tells the problem

    if it points to if (buttonLED.isChecked()) {
    it must be buttonLED is null
     
  3. Mariam

    Mariam New Member

    Joined:
    Mar 20, 2016
    Messages:
    10
    Likes Received:
    1
    the error points to the lines in bold , mAdkManager.writeSerial("1");

    Check my new post, in ADKToolkit latest version uses write function instead of writeSerial and the following is the error log

    FATAL EXCEPTION: main
    Process: com.cocosystemsolutions.www.myled, PID: 1633
    java.lang.NullPointerException
    at me.palazzetti.adktoolkit.AdkManager.write(AdkManager.java:125)
    at me.palazzetti.adktoolkit.AdkManager.write(AdkManager.java:119)
    at com.cocosystemsolutions.www.myled.MainActivity$1.onClick(MainActivity.java:53)
    at android.view.View.performClick(View.java:4438)
    at android.view.View$PerformClick.run(View.java:18422)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)
     
  4. johnsonjeven

    johnsonjeven New Member

    Joined:
    Oct 5, 2016
    Messages:
    1
    Likes Received:
    1
    The NullReferenceException is designed as a valid runtime condition that can be thrown and caught in normal program flow. It indicates that you are trying to access member fields, or function types, on an object reference that points to null. That means the reference to an Object which is not initialized.

    Johnson
     
    waltervl likes this.

Share This Page