构建React Native Android应用程序会导致错误“无法将任务[...]添加为具有该名称的任务已存在。”

时间:2017-07-24 01:58:31

标签: gradle react-native android-gradle build.gradle react-native-android

当我构建我的React Native项目时,我收到此错误(AwesomeProject是应用程序的名称):

  

配置项目':app'时出现问题。   
>无法添加任务':app:prepareAwesomeProjectReactNativeLocalizationUnspecifiedLibrary'作为具有该名称的任务已存在。

执行堆栈跟踪会返回以下内容:

(...)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: org.gradle.api.InvalidUserDataException: Cannot add task ':app:prepareAwesomeProjectReactNativeLocalizationUnspecifiedLibrary' as a task with that name already exists.
    at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:74)
    at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:97)
    at com.android.build.gradle.internal.DependencyManager.maybeCreatePrepareLibraryTask(DependencyManager.java:227)
    at com.android.build.gradle.internal.DependencyManager.setupPrepareLibraryTask(DependencyManager.java:169)
    at com.android.build.gradle.internal.DependencyManager.processLibraries(DependencyManager.java:162)
    at com.android.build.gradle.internal.DependencyManager.resolveDependencies(DependencyManager.java:157)
    at com.android.build.gradle.internal.TaskManager.resolveDependencies(TaskManager.java:364)
(...)

什么是ReactNativeLocalizationUnspecifiedLibrary

我不知道从哪里开始如何调试它,谷歌搜索没有返回任何结果。我不确定导致问题的文件是什么。

有人能指出我如何解决这个问题的正确方向吗?

1 个答案:

答案 0 :(得分:3)

糟糕。我刚刚发现了我的愚蠢错误。我导入ReactNativeLocalization为:

compile project(':react-native-localization')` 
出于某种原因,在我的build.gradle文件中

。正确的名称是“反应本地化本地化”:

{{1}}

不确定这是怎么发生的。