Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Pointer Exception #20

Open
rmushfiqur2 opened this issue Sep 14, 2018 · 6 comments
Open

Null Pointer Exception #20

rmushfiqur2 opened this issue Sep 14, 2018 · 6 comments

Comments

@rmushfiqur2
Copy link

rmushfiqur2 commented Sep 14, 2018

I am getting null pointer exception on java.lang.String.length()
Error:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at android.graphics.Canvas.drawText(Canvas.java:1703) at com.kevalpatel.passcodeview.internal.BoxTitleIndicator.drawView(BoxTitleIndicator.java:147) at com.kevalpatel.passcodeview.PinView.drawView(PinView.java:222) at com.kevalpatel.passcodeview.internal.BasePasscodeView.onDraw(BasePasscodeView.java:247) at android.view.View.draw(View.java:17526) at android.view.View.updateDisplayListIfDirty(View.java:16519) at android.view.View.draw(View.java:17295) at android.view.ViewGroup.drawChild(ViewGroup.java:3926) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3716) at android.view.View.updateDisplayListIfDirty(View.java:16514) at android.view.View.draw(View.java:17295) at android.view.ViewGroup.drawChild(ViewGroup.java:3926) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3716) at android.view.View.updateDisplayListIfDirty(View.java:16514) at android.view.View.draw(View.java:17295) at android.view.ViewGroup.drawChild(ViewGroup.java:3926) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3716) at android.view.View.updateDisplayListIfDirty(View.java:16514) at android.view.View.draw(View.java:17295) at android.view.ViewGroup.drawChild(ViewGroup.java:3926) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3716) at android.view.View.draw(View.java:17529) at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:3187) at android.view.View.updateDisplayListIfDirty(View.java:16519) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:325) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:331) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:366) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3234) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3033) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2615) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1528) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7530) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:622) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7325) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

This is my xml file:
`

<com.kevalpatel.passcodeview.PinView
    android:id="@+id/pin_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:dividerColor="@color/colorPrimaryDark"
    app:fingerprintDefaultText="Scan your finger to unlock application"
    app:fingerprintEnable="true"
    app:fingerprintTextColor="@color/colorAccent"
    app:fingerprintTextSize="@dimen/finger_print_text_size"
    app:titleTextColor="@android:color/white"/>

`

This is activity.java
`package cloud.mushfiq.buet.chargesekure;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.kevalpatel.passcodeview.PinView;
import com.kevalpatel.passcodeview.authenticator.PasscodeViewPinAuthenticator;
import com.kevalpatel.passcodeview.indicators.CircleIndicator;
import com.kevalpatel.passcodeview.keys.KeyNamesBuilder;
import com.kevalpatel.passcodeview.keys.RoundKey;

public class pinActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pin);

    PinView pinView = (PinView) findViewById(R.id.pin_view);

    final int[] correctPin = new int[]{1, 2, 3,4};
    pinView.setPinAuthenticator(new PasscodeViewPinAuthenticator(correctPin));

    pinView.setPinLength(4);

    pinView.setKey(new RoundKey.Builder(pinView)
            .setKeyPadding(R.dimen.key_padding)
            .setKeyStrokeColorResource(R.color.colorAccent)
            .setKeyStrokeWidth(R.dimen.key_stroke_width)
            .setKeyTextColorResource(R.color.colorAccent)
            .setKeyTextSize(R.dimen.key_text_size));
    pinView.setKeyNames(new KeyNamesBuilder()
            .setKeyOne(this, R.string.key_1)
            .setKeyTwo(this, R.string.key_2)
            .setKeyThree(this, R.string.key_3)
            .setKeyFour(this, R.string.key_4)
            .setKeyFive(this, R.string.key_5)
            .setKeySix(this, R.string.key_6)
            .setKeySeven(this, R.string.key_7)
            .setKeyEight(this, R.string.key_8)
            .setKeyNine(this, R.string.key_9)
            .setKeyZero(this, R.string.key_0));

    pinView.setIndicator(new CircleIndicator.Builder(pinView)
            .setIndicatorRadius(R.dimen.indicator_radius)
            .setIndicatorFilledColorResource(R.color.colorAccent)
            .setIndicatorStrokeColorResource(R.color.colorAccent)
            .setIndicatorStrokeWidth(R.dimen.indicator_stroke_width));
}

}`

this is dim file:

20dp 3dp 25dp 25dp 15dp 5dp

What is the problem going on ?

@Deresh08
Copy link

Have you managed to resolve this problem? I am getting this null pointer and i am unable to fix it.

@rmushfiqur2
Copy link
Author

No, I didn't. I ended up with using another library.

@Deresh08
Copy link

No, I didn't. I ended up with using another library.

What library did you use?

@rmushfiqur2
Copy link
Author

https://github.com/hanks-zyh/PasscodeView

@Mustafa-Altameemi
Copy link

Any solutions yet guys?

@HagosAlema
Copy link

HagosAlema commented Mar 16, 2022

I know it is too late but for anyone who still wanna use this library (even tho it is too old) and is facing the same issue:

I had the same issue and the problem was because I forgot to set the title. I solved it by adding a title. You can add title using either of following methods.
In your xml app:pin_titleText="Enter your title here"
OR
In your java or kotlin
pinview.setTitle("Enter your title here")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants