我正在尝试在我的 React Native Android 应用程序中包含一个 AAR 文件,以便我可以使用本机代码访问其功能。如何捆绑 AAR 以便本机代码可以使用 React Native Android 导入它?谢谢!
我在编译时得到的错误是这样的:
~\app\android\app\src\main\java\com\grind\GrindModule.java:13: error: package com.estimote.sdk does not exist
import com.estimote.sdk.EstimoteSDK;
^
Run Code Online (Sandbox Code Playgroud)
我进行了以下更改:
创建android/app/libs/estimote-sdk.aar.
创建 react native 原生模块(我以前做过几次,在我尝试使用 SDK 之前它工作正常)。
android/app/build.gradle
dependencies {
compile(name:'estimote-sdk', ext:'aar')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
Run Code Online (Sandbox Code Playgroud)
android/build.gradle
...
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
flatDir …Run Code Online (Sandbox Code Playgroud)