skip to Main Content

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


  1. Newer versions of React Native will require a namespace be set in build.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 the namespace entry.
    You can also try removing namespace from android/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

    Login or Signup to reply.
  2. 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.

    ...
    android {
        ...
        namespace 'com.example.namespace'
    ...
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search