简体   繁体   English

如何将 aar 文件添加到 react-native 项目?

[英]How to add aar file to react-native project?

I am building a react-native project but not able to add an aar file as a dependency.我正在构建一个 react-native 项目,但无法添加aar文件作为依赖项。

I have followed following steps我已按照以下步骤操作

  1. Created libs folder and placed aar file in that.创建 libs 文件夹并在其中放置 aar 文件。
  2. Written this in top level Gradle写在顶级Gradle中

     repositories { mavenCentral() flatDir { dirs 'libs' } }
  3. added following line to dependencies将以下行添加到依赖项

    compile project(name: "xyz", ext: 'aar')

And I am facing this error while building我在构建时遇到了这个错误

* What went wrong:
A problem occurred evaluating project ':react-native-abc'.
> Required keys [path] are missing from map {name=xyz, ext=aar}.

-> In Step 2, just make sure that while adding -> 在第 2 步中,只需确保在添加时

    flatDir{ 
       dirs 'libs' 
    }

in repositories , repository belongs to allprojects instead of buildscript.在 repositories 中,repository 属于 allprojects 而不是 buildscript。

-> In step 3 try this : -> 在第 3 步中试试这个:

    compile(name: "xyz",ext: 'aar')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM