admin 管理员组文章数量: 1086019
I'm developing a Nitro Modules native module to integrate an Android SDK into an Expo React Native app. I've successfully created mock functions with the correct typings, but I'm facing issues importing the .AAR SDK and setting up Dagger Hilt for dependency injection.
Here are the key issues I'm running into:
Manifest Configuration – The SDK requires initialization on device boot via a receiver in AndroidManifest.xml. Should this be added to the Nitro Modules manifest or the Expo prebuild manifest?
Dagger Hilt Dependency Injection – The SDK requires Hilt for proper instantiation, but I'm unsure how to set it up within the Nitro Modules ecosystem to avoid runtime errors.
AAR Import Issues – The .AAR file is placed inside the /android/libs/ directory of the Nitro Modules project, but Expo doesn’t seem to import it. As a workaround, I’ve been manually copying it to node_modules, which is not ideal.
What I’ve Tried
Added implementation(files("path_to/AndroidSDK.aar")) to build.gradle from Nitro Modules.
Placed the receiver in AndroidManifest.xml inside the Nitro Modules project.
Attempted to configure Hilt inside the Nitro module but faced issues during build.
Tried adding 'tools:replace="android:name"' in both manifests.
After placing the receiver and application setup in AndroidManifest.xml from Nitro Modules I got merge failed errors after running npx expo run:android
. Some like this:
Manifest merger failed : Attribute application@name value=(com.vitrr.example.MainApplication) from AndroidManifest.xml:17:16-47
is also present at [:sdk] AndroidManifest.xml:11:9-69 value=(com.margelo.nitro.sdk.SdkBehaviorApp).
Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml:6:5-162 to override.
SdkBehaviorApp
is the hilt factory class.
This is how my AndroidManifest.xml from Nitro Module looks like
<manifest xmlns:android=";>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".SdkBehaviorApp" >
<receiver
android:name="br.sdk.BootReceiver"
android:enabled="true"
android:exported="true"
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<!-- For HTC devices -->
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
<!-- When a new version of the app is installed over the existing one. -->
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
Has anyone successfully integrated an .AAR SDK with Dagger Hilt into a Nitro Modules native module for Expo? Any guidance on properly importing the AAR and configuring Hilt in this context would be greatly appreciated!
本文标签: androidIssues Importing an AAR SDK in a Nitro Modules Native Module for ExpoStack Overflow
版权声明:本文标题:android - Issues Importing an .AAR SDK in a Nitro Modules Native Module for Expo - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744093095a2532400.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论