Skip to content

Switch of android will cause a NullPointerException #16000

@4ndroidev

Description

@4ndroidev

Is this a bug report?

(Yes)

Have you read the Contributing Guidelines?

(No)

Environment

  1. react-native -v: 2.0.1
  2. node -v: 6.11.1
  3. npm -v: 5.3.0
  4. yarn --version: 0.27.5

Then, specify:

  • Target Platform: Android

  • Development Operating System: macOS

  • Build tools: Android Studio

Steps to Reproduce

(Write your steps here:)

  1. using library com.android.support:appcompat-v7:24.2.1
  2. using component <Switch />

Expected Behavior

display a Switch component

Actual Behavior

switch-crash

Reason

switch-reason

from this picture, line 59 and line 102 create instance of ReactSwitch;

the difference:

  1. the first one hasn't called setShowText(false), it will get the error of the red box, while calling measure.
  2. the second one has called setShowText(false), that's right.

how to fix:

follow line 59, insert a new line reactSwitch.setShowText(false);

if using com.android.support:appcompat-v7:23.0.1, it will not get this error; but i think this error can be avoided without downgrading appcompat-v7 library. Sorry for my poor english, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueInterested in collaborating? Take a stab at fixing one of these issues.Help Wanted :octocat:Issues ideal for external contributors.Resolution: LockedThis issue was locked by the bot.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions