Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

android - 在'react-native android'项目的aar库中添加node_modules(Add node_modules in aar library of a 'react-native android' project)

Is there a way to include node_modules in aar library so that a new android project using this aar library doesn't have to add these dependencies at their end as well?

(有没有一种方法可以将node_modules包含在aar库中,从而使使用此aar库的新android项目也不必在其末尾添加这些依赖项?)

I wanted to create a react native project which could be integrated in an existing android project as an aar library.

(我想创建一个react native项目,该项目可以作为aar库集成到现有的android项目中。)

Since I couldn't find a way to create an aar library of a react native project, I followed https://facebook.github.io/react-native/docs/integration-with-existing-apps to integrate react native in android app and then create an aar library of it.

(由于我找不到创建反应本机项目的Aar库的方法,因此我遵循了https://facebook.github.io/react-native/docs/integration-with-existing-apps将反应本机集成到android中应用,然后为其创建一个aar库。)

I managed to do it but the aar file created this way is of very small size (since it doesn't contain node_modules I suppose).

(我设法做到了,但是以这种方式创建的aar文件的大小非常小(因为它不包含我想的node_modules)。)

So now to use this aar in a fresh android project, I had to install all the node_modules there as well and then specify the path in project's build.gradle like maven { url "$rootDir/node_modules/react-native/android" }

(因此,现在要在一个新的android项目中使用此aar,我还必须在那里安装所有的node_modules,然后在项目的build.gradle中指定路径,例如maven {url“ $ rootDir / node_modules / react-native / android”})

Is there a way that this step is not required at the end of the app that is going to integrate the aar?

(有没有办法在将要集成aar的应用程序结束时不需要执行此步骤?)

Besides please correct me if I took a wrong approach somewhere and is there an alternative way to approach this.

(此外,如果我在某个地方采用了错误的方法,请改正我,还有其他方法可以解决此问题。)

  ask by Akshay Kumar translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...