Problem in Play Store about Broadcast Reciever

Hello,

When I import the AAB file in Google Play Console, I see this problem:

I don’t define something new in my code about it but I upgraded to latest version of Ionic and Capacitor Package and installed the package @capacitor-mlkit/barcode-scanning too.

Can someone help me to understand what is it and help me to fix it?

Thanks,
Loïc

One more information that could be related:

I added this line in the tsconfig.json file: "allowSyntheticDefaultImports": true,
Without it, I didn’t able to build or serve the app. I did see this in the content: Cannot GET /.

So by adding this line in the tsconfig file, I was able to fix this error but I don’t know it this could cause this “problem”.

Do you think I can ignore it or this is a bad thing?

It’s great that the location the error message references is empty :sweat_smile: I would double check all of your plugins to make sure they are all on versions that support Capacitor 6 / Android SDK 34.

The barcode scanning plugin has a release for v6. I searched the repo for registerReceiver and nothing was found so doubt that plugin is the cause.

Hi Tom,

Thanks for your reply :slight_smile:

I’m using the version 6.1.0 of this package so I don’t think this is related to it.

I don’t exactly know what to search…

By searching in all the files of the project I can see this:

../app/plugins/cordova.plugins.diagnostic/src/android/Diagnostic_Bluetooth.java
  124,43:             diagnostic.applicationContext.registerReceiver(bluetoothStateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
  138,45:             diagnostic.applicationContext.unregisterReceiver(bluetoothStateChangeReceiver);

../app/plugins/cordova.plugins.diagnostic/src/android/Diagnostic_Location.java
  108,43:             diagnostic.applicationContext.registerReceiver(locationProviderChangedReceiver, new IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION));
  128,45:             diagnostic.applicationContext.unregisterReceiver(locationProviderChangedReceiver);

../app/plugins/cordova.plugins.diagnostic/src/android/Diagnostic_NFC.java
  115,43:             diagnostic.applicationContext.registerReceiver(NFCStateChangedReceiver, new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED));
  135,45:             diagnostic.applicationContext.unregisterReceiver(NFCStateChangedReceiver);

This is strange because I don’t use this package (for a long time) and it is not in my package.json file either.

Do you think that this could be related to this package ?

Looks likely as it’s not setting the RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED flag.

Try running ionic cordova plugin remove cordova.plugins.diagnostic and ionic cap sync android.

In fact, I have this plugin folder with old packages:

image

I just use these 4 Cordova packages because I don’t see similar packages in Capacitor:
image
So: device-orientation to get compass feature and ios-disablesharetoedit (all is said in the name ^^). (The two other is generic or related to device-orientation).

All the other Cordova Plugin, I don’t use and need it. I just don’t know why there are still there.
Can I remove it manually or is there a command to run to do this?

I can’t run the command ionic cordova plugin remove cordova.plugins.diagnostic.

I get this error:
[ERROR] Refusing to run ionic cordova plugin inside a Capacitor project.

I can remove using npm but in this case, it doesn’t change anything for the folder “Plugins”.

Is this folder still in use (with Capacitor) or can I delete it completely (so “Plugins”)?

Sorry, was just guessing on the cordova plugin remove command. I would think ionic cap sync android should remove unused plugin code. I could be wrong.

That “plugin” folder you are referencing is here?

android/app/src/main/assets/public/plugins

I have no idea but seems like you could manually delete them. I would run ionic cap sync android afterwards and see if they reappear.

No, I talked about the folder Plugins at the root of the ionic project. This is possible that this is an old Cordova way unremoved from this project.

image


I just try by removing this folder and then run the command “npx cap sync” or “ionic cap sync android”.
Now, I don’t have any result when I search “registerReceiver”.
When I run “ionic cap run android --prod --open”, everything works fine again.
But when I submit the build in Google Play Console, I get the same error/problem :confused:

So… don’t know. I have contacted Google to have more information.

I have the ability to ignore this problem message but I don’t think this is a good thing.

Huh. As a side note, v2.0.1 of cordova-plugin-device-orientation was released in 2017. The latest is 3.0.0 which was released last year.

Hi,

Google has send my ticket to the technical support.
I should receive an answer quickly about it :crossed_fingers:

Oh yes, thanks, I will update it now.

Capacitor doesn’t use the platforms or plugins folders, if you have successfully migrated from Cordova to Capacitor you can remove those folders.

But the plugins in there are not causing the warnings neither, since they are not being used by Capacitor.

2 Likes

Hi @julio-ionic,

Thank you for the precisions :slight_smile:
I have removed those folders now (especially if they are no longer used).

I’m waiting now for the feedback of Google about this issue to fix it.

Hello guys,

To let your informed, I just received a reply from Google but with a not very satisfactory return … they told me that:

This error typically indicates an issue with how your BroadcastReceiver is declared or registered within your Android application. It’s essential to ensure that it’s correctly defined in the Manifest file and registered or unregistered appropriately within your code.
Our team specializes in Play Console support. And we have limited resources in providing technical support for app development.

I will continue to investigate but this is very unclear for me :confused:

Ugh. Since they “specialize in Play Console support”, did you tell them that their error message in the Play Console is broken and doesn’t actually say what is causing the issue when it appears it should with the verbiage “in the following location”? :sweat_smile:

Yes, I just send it the them. I’m waiting for the answer…

Here is the response:

ME: The error message in the Play Console is broken and doesn’t actually say what is causing the issue when it appears it should with the verbiage “in the following location”. So, is it possible the have the missing information to help me to identify and fix the problem please?

GOOGLE: I understand that you’re looking for more information. Rest assured, I’ve already given you all the available information from my end to help resolve the issue.

They send me just 2 links to the documentation of the registerReceiver in Kotlint and Java.
So don’t really helpful unfortunately :stuck_out_tongue:

Since everything works fine in my tests (simulators and real devices), do you think it is dangerous to ignore the issue (as suggested in the Google Play Console modal)?

Regards,
Loïc

Hi again,

After some tests and upgrades, I finally arrive to remove this “problem” in the Google Play Console.

Here is my latest changes:

  1. Update the version of the package @awesome-cordova-plugins/core from 6.4.0 to 6.8.0.
  2. Update the version of the package @awesome-cordova-plugins/device-orientation from 6.4.0 to 6.8.0.
  3. Update the version of the package cordova-plugin-device-orientation from 2.0.1 to 3.0.0.
  4. Remove the line android.defaults.buildfeatures.buildconfig=true from the file android/gradle.properties (as indicated in build warning of Android Studio).
  5. Delete the folder android/capacitor-cordova-android-plugins and rebuild it using npx cap sync.

After that, I don’t have anymore the problem in Google Play Console :champagne:

Have a nice day,
Loïc

1 Like

It sounds like you’re encountering issues with the BroadcastReceiver in your Play Store app. There are a few common reasons why a BroadcastReceiver might not behave as expected, especially with recent changes in Android’s background execution limits. Here are some troubleshooting steps and considerations:

  1. Check Android Version

    • Starting with Android 8.0 (Oreo), there have been significant changes in how background broadcasts are handled. Make sure that your app’s logic is compliant with these changes. Explicit broadcasts (directed to your app) are usually fine, but implicit broadcasts (not directed to your app) might require more attention or alternative solutions like JobIntentService or WorkManager.
  2. Manifest Declaration

    • Ensure that your BroadcastReceiver is correctly declared in the AndroidManifest.xml if you need it to work when the app is not running:
      xml




  3. Dynamic Registration

  • If your BroadcastReceiver is registered dynamically in code (using registerReceiver()), it will only be active while the app is running. Make sure you don’t rely solely on dynamic registration if you need to handle broadcasts while the app is in the background.
  1. Permissions
    • Verify that you have the necessary permissions in your manifest, especially if your broadcast is related to system events like network changes, boot completion, etc.:

xml


5. Testing
- Test the BroadcastReceiver on different devices and Android versions to ensure consistent behavior. Emulator tests are also helpful but may not always replicate the exact conditions of a physical device.

6. Play Store Specifics
- If the issue is specifically related to behavior on the Play Store, consider whether there might be restrictions or changes related to app updates, permissions, or even recent changes in Play Store policies that could affect how your app’s receivers work.

If you can provide more details on the specific issue you're facing, such as error messages or the Android version you're targeting, it might be easier to pinpoint the problem. 

Hope this helps, and feel free to share more information if you need further assistance!

This response should help guide the user through troubleshooting their BroadcastReceiver issue on the Play Store.