Skip to content

[Bug report] Broadcast error when supporting SDK 34 #695

Closed

Description

@arbelkf

SDK 34 changed the way android interacts with Broadcast.
when asking to download the model on cellular data - I get this error.

loadTesnsor::java.lang.SecurityException: com.xxx.xxxx: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for
system broadcasts

https://developer.android.com/guide/components/broadcasts#context-registered-receivers

this is the full code:

               DownloadConditions.Builder downloadConditionsBuilder = new DownloadConditions.Builder();
               allowOnlyOnWifiModel = false;
                if (allowOnlyOnWifiModel)
                 {
                     downloadConditionsBuilder.requireWifi();
                     AppendLogDebug("remote model :: require Wifi");
               }
               else
                 AppendLogDebug("remote model :: allow also cellular");
             DownloadConditions downloadConditions = downloadConditionsBuilder.build();                     

            RemoteModelManager.getInstance().isModelDownloaded(remoteModel)
                    .addOnSuccessListener(aBoolean -> {
                        if (!aBoolean)
                        {
                            RemoteModelManager.getInstance().download(remoteModel, downloadConditions)
                                    .addOnSuccessListener(new OnSuccessListener<Void>() {
                                        @Override
                                        public void onSuccess(Void unused) {
                                            RemoteModelManager.getInstance().isModelDownloaded(remoteModel)
                                                    .addOnSuccessListener(aBoolean -> {
                                                        tensorDownloaded = aBoolean;
                                                        AppendLogError("loadTesnsor::tensor model loaded::3");
                                                    });
                                        }
                                    })
                                    .addOnFailureListener(new OnFailureListener() {
                                        @Override
                                        public void onFailure(@NonNull Exception e) {
                                            AppendLogError("loadTesnsor::" + e.toString());
                                            tensorLoadOnce.set(false);
                                            ToastMeVeryShort("Wifi needed for first downloading of models", true);
                                        }
                                    });
                        }
                        else
                        {
                            tensorDownloaded = aBoolean;
                            AppendLogError("loadTesnsor::tensor model loaded::3");
                        }
                    });

if you have any workaround or information, please advice.
Google billing library just fixed this error a week ago in version 6.0.1

Activity

  1. changed the title [-]SDK 34 error[Bug report] Title for the bug[/-] [+][Bug report] Broadcast error wgile supporting SDK 34[/+] on Jul 7, 2023
  2. changed the title [-][Bug report] Broadcast error wgile supporting SDK 34[/-] [+][Bug report] Broadcast error when supporting SDK 34[/+] on Jul 7, 2023
  3. self-assigned this
    on Jul 17, 2023
  4. jackqdyulei commented on Oct 4, 2023

    @jackqdyulei
    Collaborator

    Hi arbelkf, thanks for your report and sorry for the late reply. Could you provide a bit more info?

    1. What feature are you using(sdk artifact name and version)
    2. In your build.gradle, are you use targetSdkVersion 34
    3. How your RemoteModel is created
  5. jackqdyulei commented on Nov 20, 2023

    @jackqdyulei
    Collaborator

    The issue should be fixed in our new release. Please give it a try. Thanks!

    https://developers.google.com/ml-kit/release-notes#november_7_2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions