Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7982255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:37:36+00:00 2026-06-04T10:37:36+00:00

I have a very extrange NullPointerException on my Android app. It is the piece

  • 0

I have a very extrange NullPointerException on my Android app. It is the piece of code which is causing problems:

private void setPreferences() {

        SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        ReceptionBuffer = new byte[64];     // Buffer de recepcion general de 64 bytes

        // Protocolo para cada canal (I2C, UART, SPI)
        byte[] temp = new byte[4];
        // Canal para el clock de cada canal (en caso de usar protocolos con clock como I2C,SPI)
        byte[] temp2 = new byte[4];

        for(int n=0; n < 4; ++n){
            temp[n] = Byte.decode(getPrefs.getString("protocol" + n, "0"));
            temp2[n] = Byte.decode(getPrefs.getString("channel" + n + "SCL", "0"));
        }
        for(int n=0; n < 4; ++n){
            if(DEBUG) Log.i(TAG, "LogicAnalizerView -> setPreferences() - n: " + n);
            switch(temp[n]){
            case 0:
                channelProperties[n].setProtocol(Protocol.I2C);
                break;
            case 1:
                channelProperties[n].setProtocol(Protocol.UART);
                break;
            }
            channelProperties[n].setClockSource(temp2[n]);
        }

    }

And it is the LogCat:

05-16 22:28:11.019: I/(965): LogicAnalizerView -> setPreferences() - n: 0
05-16 22:28:11.049: D/AndroidRuntime(965): Shutting down VM
05-16 22:28:11.049: W/dalvikvm(965): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-16 22:28:11.099: I/dalvikvm(965): threadid=3: reacting to signal 3
05-16 22:28:11.332: I/dalvikvm(965): Wrote stack traces to '/data/anr/traces.txt'
05-16 22:28:11.429: E/AndroidRuntime(965): FATAL EXCEPTION: main
05-16 22:28:11.429: E/AndroidRuntime(965): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.multiwork.andres/com.multiwork.andres.LogicAnalizerView}: java.lang.NullPointerException
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.os.Looper.loop(Looper.java:137)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.ActivityThread.main(ActivityThread.java:4424)
05-16 22:28:11.429: E/AndroidRuntime(965):  at java.lang.reflect.Method.invokeNative(Native Method)
05-16 22:28:11.429: E/AndroidRuntime(965):  at java.lang.reflect.Method.invoke(Method.java:511)
05-16 22:28:11.429: E/AndroidRuntime(965):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-16 22:28:11.429: E/AndroidRuntime(965):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-16 22:28:11.429: E/AndroidRuntime(965):  at dalvik.system.NativeStart.main(Native Method)
05-16 22:28:11.429: E/AndroidRuntime(965): Caused by: java.lang.NullPointerException
05-16 22:28:11.429: E/AndroidRuntime(965):  at com.multiwork.andres.LogicAnalizerView.setPreferences(LogicAnalizerView.java:361)
05-16 22:28:11.429: E/AndroidRuntime(965):  at com.multiwork.andres.LogicAnalizerView.onCreate(LogicAnalizerView.java:93)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.Activity.performCreate(Activity.java:4465)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-16 22:28:11.429: E/AndroidRuntime(965):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-16 22:28:11.429: E/AndroidRuntime(965):  ... 11 more
05-16 22:28:11.709: I/dalvikvm(965): threadid=3: reacting to signal 3
05-16 22:28:11.931: I/dalvikvm(965): Wrote stack traces to '/data/anr/traces.txt'
05-16 22:28:12.389: I/dalvikvm(965): threadid=3: reacting to signal 3
05-16 22:28:12.459: I/dalvikvm(965): Wrote stack traces to '/data/anr/traces.txt'
05-16 22:28:13.039: I/dalvikvm(965): threadid=3: reacting to signal 3
05-16 22:28:13.230: I/dalvikvm(965): Wrote stack traces to '/data/anr/traces.txt'
05-16 22:28:17.912: I/Process(965): Sending signal. PID: 965 SIG: 9

The problem according to LogCat is in the line channelProperties[n].setProtocol(Protocol.I2C);. setPreferences() is being called from onCreate() method and before this as a global variable i have:

private static LogicChannelProperties[] channelProperties = new LogicChannelProperties[4];

So is strange because i have allocated the space. Why i am getting this ? It is my class:

import com.multiwork.andres.LogicData.Protocol;

public class LogicChannelProperties {

    private Protocol mProtocol;
    private int clockSource;

    /**
     * Setea el protocolo a usar (ej: Protocol.I2C/SPI...)
     * @author Andres Torti
     * @param type es el protocolo a usar (ej: Protocol.I2C/SPI...)
     */
    public void setProtocol (Protocol type){
        mProtocol = type;
    }

    /**
     * Obtiene el protocolo
     * @author Andres Torti
     * @return variable tipo Protocol (ej: Protocol.I2C/SPI...)
     */
    public Protocol getProtocol (){
        return mProtocol;
    }

    /**
     * Setea el canal que actua como fuente de clock
     * @author Andres Torti
     * @param sourceChannel es el numero del canal >0
     */
    public void setClockSource (int sourceChannel){
        clockSource = sourceChannel;
    }

    /**
     * Obtiene el canal que actua como fuente de clock
     * @author Andres Torti
     * @return int, numero del canal
     */
    public int getClockSource (){
        return clockSource;
    }

}

Thank you for your time 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:37:38+00:00Added an answer on June 4, 2026 at 10:37 am

    That exception just means it can’t start the Activity because it threw an exception during creation time. The actual problem is a NullPointerException that’s occurring on line# 361 in LogicAnalizerView.java.

    I’m guessing it’s the channelProperties[] array that isn’t initialized properly since it looks like you’re creating the array but not populating it with anything.

    So you need something like channelProperties[0] = new ChannelProperties(); //etc.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have very simple iPhone app, which uses just UIButtons , UIlabels , UITableView
I have very unique problem. My app has UINavigationCnotroller with a set of UIViewController's.
I have very simple code and I am not sure why the Foo function
I have very similar multithreaded code elsewhere in my codebase that works fine, but
I have very simple code: List<String> list = new ArrayList<String>(); String a = a;
I have very simple aspx page & code: <%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=_Default
i have very simple code that i making partial postback by jquery and i
I have very little SAP ERP knowledge. I wrote some code to create a
I have very bad code written in php. It consumes a lot memory, and
I have very simple window where I have 2 buttons - one for cancel,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.