我正在尝试将一个AAR文件包含到我的React Native Android应用程序中,以便可以使用本地代码访问其功能。如何捆绑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;
^
我已经做出了以下更改:
创建 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
}
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 {
dirs 'libs'
}
}
}
这是关于包含SDK的指示:https://github.com/Estimote/Android-SDK#installation。详细手动安装说明请参考:https://github.com/Estimote/Android-SDK/blob/master/Docs/manual_installation.md#estimote-sdk-for-android-manual-installation。