react-native-webview: nullPointerException when linking react-native-webview
Hi there, I’m getting the following error when trying to run react-native run-android
after installing react-native-webview
. Not sure if I’ve missed a very obvious step or not. The same configuration works in iOS.
Versions
react-native-cli: 2.0.1
react-native: 0.57.7
react-native-webview: 2.14.0
Error
A problem occurred configuring project ':react-native-webview'.
java.lang.NullPointerException (no error message)
Reproduction steps
react-native init app
cd app
yarn add react-native-webview
react-native link react-native-webview
react-native run-android
Debug log at crash
14:11:18.960 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] ADDED TRANSFORM(debugAndroidTest):
14:11:18.960 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] Name: mergeJniLibs
14:11:18.960 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] Task: transformNativeLibsWithMergeJniLibsForDebugAndroidTest
14:11:18.960 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] InputStream: OriginalStream{name=ext-libs-res-plus-native-restricted-copy, scopes=[EXTERNAL_LIBRARIES], contentTypes=[NATIVE_LIBS], fileCollection=configuration ':react-native-webview:debugAndroidTestRuntimeClasspath'}
14:11:18.960 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] InputStream: OriginalStream{name=ext-libs-native, scopes=[EXTERNAL_LIBRARIES], contentTypes=[NATIVE_LIBS], fileCollection=configuration ':react-native-webview:debugAndroidTestRuntimeClasspath'}
14:11:18.961 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] InputStream: OriginalStream{name=sub-projects-res-plus-native-restricted-copy, scopes=[SUB_PROJECTS], contentTypes=[NATIVE_LIBS], fileCollection=file collection}
14:11:18.961 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] InputStream: OriginalStream{name=sub-projects-native, scopes=[SUB_PROJECTS], contentTypes=[NATIVE_LIBS], fileCollection=file collection}
14:11:18.961 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] InputStream: OriginalStream{name=mergedJniFolder, scopes=[PROJECT], contentTypes=[NATIVE_LIBS], fileCollection=file collection}
14:11:18.961 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] InputStream: OriginalStream{name=local-ndk-build, scopes=[PROJECT], contentTypes=[NATIVE_LIBS], fileCollection=file collection}
14:11:18.961 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager] OutputStream: IntermediateStream{scopes=[PROJECT, SUB_PROJECTS, EXTERNAL_LIBRARIES], contentTypes=[NATIVE_LIBS], fileCollection=file collection}
14:11:18.961 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project :react-native-webview - Registering model element 'tasks.transformNativeLibsWithMergeJniLibsForDebugAndroidTest' (hidden = false)
14:11:18.961 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project :react-native-webview - Registering model element 'tasks.javaPreCompileDebugAndroidTest' (hidden = false)
14:11:18.962 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project :react-native-webview - Registering model element 'tasks.compileDebugAndroidTestJavaWithJavac' (hidden = false)
14:11:18.962 [INFO] [com.android.build.gradle.tasks.factory.JavaCompileConfigAction] Using incremental javac compilation for :react-native-webview debugAndroidTest.
14:11:18.971 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Configure project :react-native-webview'
14:11:18.971 [null] [org.gradle.internal.progress.DefaultBuildOperationExecutor]
14:11:18.971 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Configure build'
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred configuring project ':react-native-webview'.
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.NullPointerException (no error message)
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
14:11:18.972 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 24 (5 by maintainers)
TLDR: either use java 1.8 or update gradle
Can you please run ‘java -version’ and give me the output ? If it’s 10 this is your issue and you need to use 8
Can confirm issue with latest
react-native-webview
and clean project after init. The only workaround for me is to downgradenpm install --save react-native-webview@v2.8.0
Thanks for the kotlin clarification.
I fixed my issue. I am using a “staging” buildType, I needed to add a matchingFallbacks in order to build correctly the app with assembleStaging.
Something like: in android/app/build.gradle:
Just so you know: https://stackoverflow.com/questions/40108471/java-lang-nullpointerexception-no-error-message-apk-building https://github.com/fastlane/fastlane/issues/12646 https://github.com/react-community/create-react-native-app/issues/603
@xavieramoros Unless your using kotlin in your project I dont think you need to include:
In my case I have kotlin code that used an older version that caused a conflict when adding this package.
Success! I used this extremely lazy way to get to Gradle 4.6 on my project:
react-native run-android
builds, and Android Studio no longer bugs me to update Gradle. Win-win.