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. Gurux.DLMS.Android Example - Fails On Android 15 (API 35)

Gurux.DLMS.Android Example - Fails on Android 15 (API 35)

By rajput_saurabh07, 7 August, 2025
Forums
Gurux DLMS for Android

Hello Gurux Team and Community,

I'm writing to share an issue I encountered with the official Gurux.DLMS.Android example project from GitHub when running it on newer versions of Android.

The Problem
The application works perfectly on a device running Android 12 (API 31). However, when I try to run the same project on a device with Android 15 (API 35), the app is not working at all.

Diagnosis
The project's build.gradle.kts file targets SDK 34. This means that on an Android 15 device, the OS strictly enforces all the behavioral changes required for apps targeting modern SDKs.

The example project in its current state is missing a few key compliance updates, causing it to fail on newer Android versions. The main issues are:

UI Update on Background Thread: The app crashes on the splash screen (GXSplashScreen.java) because it tries to update a TextView from a background thread.

Missing Notification Permission: The AndroidManifest.xml is missing the POST_NOTIFICATIONS permission, which is mandatory for apps targeting Android 13+ that need to show notifications (required for foreground services).

Missing Foreground Service Declaration: The manifest does not declare a foregroundServiceType, which is required for apps targeting Android 14+ to run services for hardware communication.

Incorrect android:exported Flag: MainActivity is set to android:exported="false" but has an intent filter for USB device attachment, preventing the system from launching the app.

Solution
I have made the following changes to the code and manifest, which resolve all the issues and allow the app to run correctly on Android 15.

1. Code Fix in GXSplashScreen.java

Wrapped the UI update calls in runOnUiThread to prevent the app from crashing on launch.

Java

// Inside the Thread's run() method in GXSplashScreen.java

// ...
runOnUiThread(() -> loading.setText("Loading OBIS codes."));
// ...
runOnUiThread(() -> loading.setText("Loading manufacturer settings."));
// ...
2. Updates to AndroidManifest.xml

I updated the manifest to include the necessary permissions, declare the foreground service, and correct the exported flag.

XML

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"&gt;

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<uses-permission android:name="android.permission.INTERNET" />

<application ...>

<activity
android:name=".MainActivity"
android:exported="true" android:theme="@style/Theme.GuruxDLMSAndroid.NoActionBar">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>

<service
android:name="gurux.common.GXForegroundService"
android:foregroundServiceType="connectedDevice" />

</application>

</manifest>

I hope this information is helpful. Still nothing is happening in the app.

Best regards,

Saurabh

Profile picture for user Kurumi

Kurumi

5 months 2 weeks ago

Hi Saurabh, We tested this…

Hi Saurabh,

We tested this with a few Android 15 devices and everything worked as expected.
runOnUiThread is added just in case.

permission and USB_DEVICE_ATTACHED are included from the implemented media so they are not needed.

GXForegroundService is something that you have implemented and it's not part of gurux.common.

Can you get the latest version and let me know if you have problems?

BR,
Mikko

rajput_saurabh07

5 months 1 week ago

Hi, I'm using a OnePlus 11…

Done..Working now. Thanks

rajput_saurabh07

5 months 1 week ago

Android NullPointerException…

Android NullPointerException in ArrayAdapter when selecting BaudRate. App is crashing here.

Profile picture for user Kurumi

Kurumi

5 months ago

Hi, This is now fixed…

Hi,

This is now fixed. Publishing to Maven Central is changed and that caused some delays and modifications. Get version 3.0.1.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 01/20/2026 - 10:38
    gurux.dlms.java 4.0.89
  • Wed, 01/14/2026 - 14:29
    Gurux.DLMS.Python 1.0.196
  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5
  • Mon, 12/15/2025 - 08:11
    Gurux.DLMS.Net 4.0.87
  • Fri, 12/12/2025 - 08:38
    Gurux.DLMS.Python 1.0.195

New forum topics

  • Generic Profile- gxGet with selector=2: different behaviour on cpp and cimplementation
  • DLMS Client–Server Communication Over GPRS Fails With Dynamic IP
  • Pre-established connection questions
  • writing Error "Service not allowed"
  • High GMAC meters can’t authenticate – can’t read invocation counter
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin