未指定命名空间。请在模块的 build.gradle 文件中指定命名空间

Jel*_*ish 4 android gradle react-native expo

当我尝试使用以下命令构建反应本机应用程序时,我不断收到错误消息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'
           }
Run Code Online (Sandbox Code Playgroud)

然而,在android/app/build.gradle

...
android {
    ndkVersion rootProject.ext.ndkVersion
    compileSdkVersion rootProject.ext.compileSdkVersion
    namespace 'com.wilburcoding.BirdSoundSearch'
...
Run Code Online (Sandbox Code Playgroud)

网上似乎没有任何答案对这个问题有有效/有效的答案。看来这个问题可能源自react-native-webview. 这是依赖问题还是 gradle 问题?

小智 7

我在这里遇到了同样的问题。转到 Android 应用程序中的 graddle 脚本列表。找到给你带来问题的那个(在我的例子中是 build.gradle (Module: react-native-maps)

然后打开它并在 android 下添加您的命名空间。

...
android {
    ...
    namespace 'com.example.namespace'
...
}
Run Code Online (Sandbox Code Playgroud)