I keep getting an error when I tried to build my react-native app with npx expo run:android
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
> A problem occurred configuring project ':react-native-webview'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
android {
namespace 'com.example.namespace'
}
However, in android/app/build.gradle
...
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
namespace 'com.wilburcoding.BirdSoundSearch'
...
There doesn’t appear to be any answers online that have valid/working answers to this problem.
It does appear this issue may have originated from react-native-webview
. Is this an issue with the dependency or a gradle issue?
2
Answers
Newer versions of React Native will require a
namespace
be set inbuild.gradle
files. To correct the issue, you should try bumping the dependency in question (in this case,react-native-webview
) to a newer version which contains thenamespace
entry.You can also try removing
namespace
fromandroid/app/build.gradle
, as I don’t believe it’s strictly needed in React Native 71 or 72.To learn more about why these changes have been made, take a look at this GitHub discussion: https://github.com/react-native-community/discussions-and-proposals/issues/671
I was having the same issue here. Go to the list of graddle scripts in your android app. Locate the one that is giving you issue (in my case it was
build.gradle (Module: react-native-maps)
Then open it and add your namespace there, under android.