Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Integrating Gurux.DLMS.Android Library Into React Native App

Integrating Gurux.DLMS.Android Library into React Native App

By Akash, 12 April, 2024
Forums
Gurux DLMS for Android

I need to integrate DLMS meter communication into a React Native mobile application.

Here are a few specific questions I have:
React Native JS class Through i am opening Android Activity and getting data
but i need to do click functionality in React Native can any one help me out of this solution

Profile picture for user Kurumi

Kurumi

1 year 1 month ago

Hi, Our clients are not…

Hi,

Our clients are not using React Native at the moment, so I can't help you with this.

BR,
Mikko

delanou

1 year ago

You'll need to include Gurux…

You'll need to include Gurux DLMS Android library as Native Module in React Native (v0.62.3):

1. Generate the Gurux DLMS client library (.aar file)*. (Change default name "app-debug" to something meaningful)

2. Copy .aar file into /YOUR_REACT_NATIVE_APP/android/app/libs
(If you don't have libs folder, create a new one)

3. Add the following dependencies to android/app/build.gradle:

implementation files('libs/gurux_dlms.aar')
implementation("org.gurux:Gurux.Common.Android:2.0.1")
implementation("org.gurux:gurux.serial.android:2.0.1")

4. Modify the minSdkVersion in the android/build.gradle file from 21 to 28.

5. Modify android:allowBackup="false" to android:allowBackup="true" in the android/app/src/main/AndroidManifest.xml file.

6. Copy and paste the GXDevice.java file from Gurux DLMS Android repo -> https://github.com/Gurux/Gurux.DLMS.Android/blob/master/Java/app/src/ma… to android/app/src/main/java/com/YOUR_PROJECT/GXDevice.java.

7. Create the files DLMSClientModule.java, DLMSClientPackage.java (or name those files to anything you like), and modify MainApplication.java to include DLMSClientPackage. (Read this: https://reactnative.dev/docs/native-modules-android)

8. In the file where you'll use the native methods, add:

import {
NativeModules,
} from 'react-native';
const MyNativeModule = NativeModules.YOUR_MODULE_NAME_HERE;

*To generate a .aar file in Android Studio, follow these steps:

1. Clone the GitHub repository - Gurux/Gurux.DLMS.Android: Gurux DLMS library for Android.
2. Open it with Android Studio.
3. Verify/wait for Gradle to download all necessary dependencies for the project.
4. Go to Build > Clean Project.
5. Go to Build > Rebuild Project.
6. Find the generated file (.aar) in ./AndroidStudioProjects/guruxDLMS/guruxlibrary/build/outputs.

Profile picture for user Kurumi

Kurumi

1 year ago

Hi delanou, Thank you for…

Hi delanou,

Thank you for this information. It's interesting if Java packages can be used from React Native without any changes. This means that you can use builds from Maven Central and you only need to add those components for your grade like this:

implementation 'org.gurux:Gurux.Common.Android:2.0.2'
implementation 'org.gurux:gurux.serial.android:2.0.3'
implementation 'org.gurux:gurux.dlms.android:2.0.4'

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 05/20/2025 - 08:40
    gurux.dlms.c 9.0.2505.2001
  • Mon, 05/19/2025 - 10:19
    gurux.net.java 1.0.30
  • Mon, 05/19/2025 - 10:00
    gurux.dlms.c 9.0.2505.1901
  • Thu, 05/15/2025 - 16:26
    gurux.dlms.c 9.0.2505.1501
  • Wed, 05/14/2025 - 08:30
    gurux.dlms.c 9.0.2505.1401

New forum topics

  • HDLC Adress resolver configuration
  • Reading all "Data" object type parameter together
  • com_read getting failed for billing profile and instantaneous profile
  • Simulator connection closed
  • Regarding the dlms android project
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin