react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Attempt to invoke virtual method 'void com.facebook.react.views.textinput.ReactEditText$InternalKeyListener.setInputType(int)' on a null object reference

Open michaelVictoriaDev opened this issue 4 years ago • 29 comments

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

image

React Native version:

Run react-native info in your terminal and copy the results here.

ystem:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
    Memory: 4.02 GB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/admin/.rvm/rubies/ruby-2.6.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 27, 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.1, 30.0.2, 30.0.3
      System Images: android-29 | Automotive with Play Store Intel x86 Atom, android-29 | Android TV Intel x86 Atom, android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-30 | Google Play ARM 64 v8a, android-30 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_265 - /usr/bin/javac
    Python: 2.7.10 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.4 => 0.63.4
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Random error, yesterday before I shutdown my computer the error appear.

michaelVictoriaDev avatar Jul 01 '21 07:07 michaelVictoriaDev

I have two React Native projects with similar environments but the same problem occurred in only one of them

Xiaoaomi147 avatar Jul 01 '21 07:07 Xiaoaomi147

My multidex config was the culprit in my projects. If you have something like this that forces androidx.appcompat to use specific versions, you might try removing it.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "androidx.appcompat") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "1.+"
            }
        }
    }
}

chadsmith avatar Jul 01 '21 17:07 chadsmith

@chadsmith

I attempted to apply your work-around; first as my project was, then with a cache clean and rebuild. Unfortunately, the same error occurs.

I did figure out by messing around and isolating components, the issue is coming from React Native's TextInput component.. But unsure how to continue on to fix that...

GoodGameGabe avatar Jul 02 '21 05:07 GoodGameGabe

I found this https://github.com/facebook/react-native/pull/29452/files

add the edit_text.xml and other's... following steps but seems to have same problem.

michaelVictoriaDev avatar Jul 02 '21 05:07 michaelVictoriaDev

Changing TextInput (react-native) to Input (native-base) the error is the same.

michaelVictoriaDev avatar Jul 02 '21 05:07 michaelVictoriaDev

Upon investigation its because of the component of TextInput.

michaelVictoriaDev avatar Jul 02 '21 06:07 michaelVictoriaDev

not sure if they fix in the next version of RN ???

michaelVictoriaDev avatar Jul 02 '21 07:07 michaelVictoriaDev

Same problem detected using RN version 0.63.3. New builds made after 29/6 have that problem with react-native TextInput (source code of our project has not been changed) . Does anyone know if the problem doesn't occur using RN 0.64?

simonecorsato avatar Jul 02 '21 09:07 simonecorsato

@simonecorsato I try to upgrade RN 0.64.2 but still the same error TextInput

michaelVictoriaDev avatar Jul 02 '21 09:07 michaelVictoriaDev

Thanks for your response. The problem seems be at build time, because every build made after 29/6 include that problem.

simonecorsato avatar Jul 02 '21 09:07 simonecorsato

@simonecorsato Mine build successfully but when it will render the text input the error shows.

michaelVictoriaDev avatar Jul 02 '21 09:07 michaelVictoriaDev

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

gxxgcn avatar Jul 02 '21 09:07 gxxgcn

Same here. I wanted to say that, starting from the same source code, the app made before 29/6 didn't have that problem, while the apps builded after 29/6 show that error when the text input is going to be rendered

@simonecorsato Mine build successfully but when it will render the text input the error shows.

simonecorsato avatar Jul 02 '21 09:07 simonecorsato

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

I dont have implementation 'androidx.appcompat: .... but i try to added implementation implementation 'androidx.appcompat:appcompat:1.3.0' still having the same problem

michaelVictoriaDev avatar Jul 02 '21 10:07 michaelVictoriaDev

My multidex config was the culprit in my projects. If you have something like this that forces androidx.appcompat to use specific versions, you might try removing it.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "androidx.appcompat") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "1.+"
            }
        }
    }
}

Try to use details.useVersion "1.3.0"

It seems that this issue caused by androidx.appcompat 1.4.0

gxxgcn avatar Jul 02 '21 10:07 gxxgcn

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

I dont have implementation 'androidx.appcompat: .... but i try to added implementation implementation 'androidx.appcompat:appcompat:1.3.0' still having the same problem

Same here.

simonecorsato avatar Jul 02 '21 11:07 simonecorsato

My multidex config was the culprit in my projects. If you have something like this that forces androidx.appcompat to use specific versions, you might try removing it.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "androidx.appcompat") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "1.+"
            }
        }
    }
}

Try to use details.useVersion "1.3.0"

It seems that this issue caused by androidx.appcompat 1.4.0

Unfortunately I can't find a similar configuration in my project

simonecorsato avatar Jul 02 '21 11:07 simonecorsato

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

this solution seemed to work for me. apparently there's something to do with appcompat just like @gxxgcn said.

ivanmateus avatar Jul 02 '21 15:07 ivanmateus

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

this solution seemed to work for me. apparently there's something to do with appcompat just like @gxxgcn said.

I got it to work again by setting this in my dependencies. (I had to downgrade multidex as well)

implementation "androidx.multidex:multidex:2.0.0"
implementation 'androidx.appcompat:appcompat:1.3.0'

GoodGameGabe avatar Jul 02 '21 15:07 GoodGameGabe

I have the same issue. It was caused by node_modules/react-native-audio/android/build.gradle. Change the version from + to 1.3.0 fixed the issue for me. 1.4.0-alpha02 may also work.

implementation 'androidx.appcompat:appcompat:1.3.0'

halaei avatar Jul 03 '21 11:07 halaei

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

this solution seemed to work for me. apparently there's something to do with appcompat just like @gxxgcn said.

I got it to work again by setting this in my dependencies. (I had to downgrade multidex as well)

implementation "androidx.multidex:multidex:2.0.0"
implementation 'androidx.appcompat:appcompat:1.3.0'

Do you have this snippet ? @GoodGameGabe

defaultConfig {
    applicationId 'com.xxx.xxxx'
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 6
    versionName '1.0.15'
    multiDexEnabled true // <-add this
}

michaelVictoriaDev avatar Jul 03 '21 12:07 michaelVictoriaDev

I try to update .1 version "react-native": "0.63.3" to "react-native": "0.63.4"

the error looks like this image

my snippet in android > app > build.gradle looks like this

apply plugin: 'com.android.application'

import com.android.build.OutputFile

project.ext.react = [
    enableHermes: false,  // clean and rebuild if changing
    extraPackagerArgs: ['--reset-cache']
]

apply from: '../../node_modules/react-native/react.gradle'


def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = true
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get('enableHermes', false)

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId 'com.xxx.xxx'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 6
        versionName '1.0.15'
        multiDexEnabled true // <-add this
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    configurations.all {
        resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.12.+'
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ['armeabi-v7a': 1, 'x86': 2, 'arm64-v8a': 3, 'x86_64': 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'androidx.appcompat:appcompat:1.4.0-alpha02'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0'
    compile project(':react-native-android-location-enabler')
    // implementation('com.squareup.okhttp3:okhttp-urlconnection:4.4.1')
    implementation 'com.google.firebase:firebase-messaging:21.1.0'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:0.63.4'  // From node_modules

    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'

    implementation project(':react-native-push-notification')
    compile project(':react-native-push-notification')

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        def hermesPath = '../../node_modules/hermes-engine/android/'
        debugImplementation files(hermesPath + 'hermes-debug.aar')
        releaseImplementation files(hermesPath + 'hermes-release.aar')
    } else {
        implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file('../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle'); applyNativeModulesAppBuildGradle(project)

did anyone here same snippet ?

michaelVictoriaDev avatar Jul 03 '21 13:07 michaelVictoriaDev

project-report plugin helped me to figure out dependency issues. I put my setup here, in case it you are interested. It may be a little bit messy. If you have a better solution let me know.

Installation

in android/app/build.gradle:

apply plugin: 'project-report'

Dump dependencies

The following command dump all the android dependencies in android/dependencies.txt:

cd android && ./gradlew projectReport && cp ./app/build/reports/project/dependencies.txt ./dependencies.txt

Run the command every time you build and keep dependencies.txt in version control. If anything like this issue happens it gives you a hint which package causes the issue.

Find unstable/dangerous dependency versions

The following command find dependencies with + or unstable alpha versions. If the versions happen to cause any trouble, restrict them in build.graddle of the corresponding node_modules packages.

grep -P "(?<!org\.webkit:android-jsc)(?<!com\.facebook\.react:react-native):(\+|(.*)alpha)" ./dependencies.txt | sed -e 's/^[ |+\-]*//g' | sort | uniq

halaei avatar Jul 03 '21 14:07 halaei

Hi @halaei thanks for this that's give's me a brighter side, for those who don't have any idea where's the cultript try to check all the dependencies and remove all unwanted package.

michaelVictoriaDev avatar Jul 05 '21 03:07 michaelVictoriaDev

I have the same issue. It was caused by node_modules/react-native-audio/android/build.gradle. Change the version from + to 1.3.0 fixed the issue for me. 1.4.0-alpha02 may also work.

implementation 'androidx.appcompat:appcompat:1.3.0'

Same situation here. The version change in react-native-audio fixed.

simonecorsato avatar Jul 05 '21 12:07 simonecorsato

this work for me; deleted node-modules folder and install using npm i, update all dependencies

zunkraz avatar May 08 '22 03:05 zunkraz

@michaelVictoriaDev @Xiaoaomi147 @zunkraz @simonecorsato Same issue i am getting Can you please help me to resolve this issue. "react": "17.0.1", "react-native": "0.64.2",

codal-mpawar avatar Jun 08 '22 11:06 codal-mpawar

replace implementation 'androidx.appcompat:appcompat:+' with implementation 'androidx.appcompat:appcompat:1.3.0' it works for me .

where should i change this changings?

Asadaial avatar Jan 16 '23 07:01 Asadaial

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 19 '24 05:02 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Feb 26 '24 05:02 github-actions[bot]