我正在测试我的React Native库,该库导出了一些本机功能。我正在遵循此指南来测试库而不发布它: https://medium.com/@the1mills/how-to-test-your-npm-module-without-publishing-it-every-5-minutes-1c4cb4b369be 。但是,我的库中的源代码打包在AAR文件中。我一直在遵循本指南将AAR添加到库项目:https://medium.com/@notestomyself/how-to-include-external-aar-file-using-gradle-6604b378e808。而且它在Android Studio中构建良好,并且我能够访问AAR中存储的类和方法。问题是当我尝试运行时:
react-native run-android
我收到此错误:
> Task :app:preDebugBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find :TrueConfSDK:.
Required by:
project :app > project :react-native-trueconf-sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
其中TrueConfSDK.aar是带有源代码的文件。更准确地说-我正在运行命令npm pack
,然后使用npm install <absolute path> & react-native link
安装tgz文件。那么如何将AAR添加到React Native库中。