Why I am Getting Error 'Channel is unrecoverably broken and will be disposed!'
Asked Answered
W

31

155

When I try to launch my AndEngine Activity, I get this error:

ERROR/InputDispatcher(21374): channel '4122e148 my.package.AcGame (server)' ~ Channel is unrecoverably broken and will be disposed!

The app doesn't crash, but there's a black screen and the device doesn't react to pressing the 'back' or 'home' buttons.

Does anyone know what the problem is?

Windjammer answered 17/9, 2012 at 12:59 Comment(4)
Not much can be guessed from the information you gave (Please add more). But this might help: https://mcmap.net/q/120731/-inputdispatcher-error-closed Check for memory leaks.Polson
That error shows up after an app crashed (or was force-stopped). The part in Android that forwards input events (touchscreen presses etc) to your app has noticed that it's target is no longer there. Look for an error that happens before that one.Speculative
@uncle Lem , Bro even i am stuck up in the same issue . I cant perform any operations until i reboot the phone. did u get any solution ? I am fed up with this issue..Sweetie
@uncle So did you find the solution?Kealey
D
53

One of the most common reasons I see that error is when I am trying to display an alert dialog or progress dialog in an activity that is not in the foreground. Like when a background thread that displays a dialog box is running in a paused activity.

Debonair answered 18/12, 2012 at 6:56 Comment(2)
Set the dialog to null in onPause, and check for null before you display the dialog in the background thread.Debonair
In my case I got the error because I commented out onResume(), onStart, onStop, onPause, onDestroy, and onLowMemory methods. Thank you @LouMorda for the hint!Hallock
I
18

I think that You have memory leaks somewhere. You can find tips to avoid leaking memory here. Also you can learn about tools to track it down here.

Incunabula answered 6/3, 2014 at 11:18 Comment(0)
F
10

Have you used another UI thread? You shouldn't use more than 1 UI thread and make it look like a sandwich. Doing this will cause memory leaks.

I have solved a similar issue 2 days ago...

To keep things short: The main thread can have many UI threads to do multiple works, but if one sub-thread containing a UI thread is inside it, The UI thread may not have finished its work yet while its parent thread has already finished its work, this causes memory leaks.

For example...for Fragment & UI application...this will cause memory leaks.

getActivity().runOnUiThread(new Runnable(){
    public void run() { //No.1          
        ShowDataScreen();

        getActivity().runOnUiThread(new Runnable(){
            public void run() { //No.2
                Toast.makeText(getActivity(), "This is error way",Toast.LENGTH_SHORT).show();
            }});// end of No.2 UI new thread
    }
});// end of No.1 UI new thread

My solution is rearrange as below:

getActivity().runOnUiThread(new Runnable(){
    public void run() {//No.1
        ShowDataScreen();
    }}); // end of No.1 UI new thread       

getActivity().runOnUiThread(new Runnable(){
    public void run() {//No.2
        Toast.makeText(getActivity(), "This is correct way",Toast.LENGTH_SHORT).show();
    }
}); // end of No.2 UI new thread for you reference.

Fungi answered 14/11, 2014 at 4:38 Comment(0)
F
5

I got similar error (my app crashes) after I renamed something in strings.xml and forgot to modify other files (a preference xml resource file and java code).

IDE (android studio) didn't showed any errors. But, after I repaired my xml files and java code, app ran okay. So, maybe there are some small mistakes in your xml files or constants.

Freed answered 31/10, 2013 at 2:34 Comment(3)
Too generalized to be understood though :)Kneehigh
I invalidated data and restarted IDE and problem was solved. Maybe because the error was because of what u have mentioned.Cerous
@AleksadnreBibilashvili Dude..You Saved my day..i invalidated and restart the ide,, then it revealed the possible crash...Norford
U
5

You can see the source code about this output here:

void InputDispatcher::onDispatchCycleBrokenLocked(
        nsecs_t currentTime, const sp<Connection>& connection) {
    ALOGE("channel '%s' ~ Channel is unrecoverably broken and will be disposed!",
            connection->getInputChannelName());
    CommandEntry* commandEntry = postCommandLocked(
            & InputDispatcher::doNotifyInputChannelBrokenLockedInterruptible);
    commandEntry->connection = connection;
}

It's cause by cycle broken locked...

Unchurch answered 13/3, 2015 at 7:43 Comment(1)
Can you elaborate, what does cycle broken locked mean?Eppes
C
5

I had the same problem. To solve the error: Close it on the emulator and then run it using Android Studio.

The error happens when you try to re-run the app when the app is already running on the emulator.

Basically the error says - "I don't have the existing channel anymore and disposing the already established connection" as you have run the app from Android Studio again.

Credible answered 3/5, 2016 at 4:26 Comment(1)
Closed the Genymotion emulator. Opened the emulator again.Ran it. No app crashing this time :)Litigation
M
2

I had the same problem but mine was Due To an Android database memory leak. I skipped a cursor. So the device crashes so as to fix that memory leak. If you are working with the Android database check if you skipped a cursor while retrieving from the database

Militarize answered 27/8, 2013 at 11:53 Comment(1)
I didn't used no databases in that app. Seems to me that there's a LOT of options that may cause that error.Windjammer
P
2

I had the same problem. Mine was due to a third jar, but the logcat did not catch the exception, i solved by update the third jar, hope these will help.

Pianola answered 22/10, 2015 at 9:14 Comment(0)
C
2

As I faced this error, somewhere in your code your funcs or libraries that used run on different threads, so try to call all code on the same thread , it fixed my problem.

If you call methods on WebView from any thread other than your app's UI thread, it can cause unexpected results. For example, if your app uses multiple threads, you can use the runOnUiThread() method to ensure your code executes on the UI thread:

Google reference link

Conglobate answered 4/2, 2019 at 12:17 Comment(0)
H
2

It's obvious this creeps up due to many issues. For me, I was posting several OneTimeWorkRequest, each accessing a single room database, and inserting into a single table.

Making the DAO functions suspended, and calling them within the coroutine scope of the worker fixed this for me.

Hunk answered 20/10, 2020 at 13:40 Comment(2)
Could you say more what you mean with "Calling them within the coroutine scope of the worker fixed this"? I think I have the same issue but I am not able to fix itCharters
@Charters If the DAO functions are suspended, then they have to be called from some coroutine scope. For my case, the database updates were being performed inside a OneTimeWorkRequest which as an Android Worker, has an extension library which surfaces the coroutine scope for the worker. Even more specific, these requests were appended to one-another, so with many requests at one time, I'm not sure if coroutines alone will handle queuing updates to the database. In this case (without a worker that is queuing requests), it might be worth looking into Kotlin's Mutex syntax.Hunk
M
1

I was having the same problem too. In my case was caused when trying to reproduce videos with a poor codification (demanded too much memory). This helped me to catch the error and request another version of the same video. https://mcmap.net/q/120732/-android-media-player-error-100-0

Mutinous answered 19/2, 2014 at 15:53 Comment(0)
F
1

It happened for me as well while running a game using and-engine. It was fixed after i added the below code to my manifest.xml. This code should be added to your mainactivity.

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|mcc|mnc"
Fitzsimmons answered 15/10, 2014 at 20:17 Comment(0)
M
1

Reading through all contributions, it looks like many different origins exhibit cause this same problem symptoms.

In my case for instance - I got this problem as soon as I added

android:progressBackgroundTintMode="src_over"

to my progress bar properties. I think the GUI designer of ADT is known for several bugs. Hence I assume this is one of them. So if you encounter similar problem symptoms (that just do not make sense) after playing with your GUI setup, just try to roll back what you did and undo your last GUI modifications.

Just press Ctrl+z with the recently modified file on screen.

Or:

The Version Control tool could be helpful. Open the Version Control panel - choose Local Changes tab and see recently modified (perhaps .xml) files.

Right click some most suspicious one and click Show Diff. Then just guess which modified line could be responsible.

Good luck :)

Marya answered 6/12, 2016 at 16:33 Comment(0)
R
1

In my case these two issue occurs in some cases like when I am trying to display the progress dialog in an activity that is not in the foreground. So, I dismiss the progress dialog in onPause of the activity lifecycle. And the issue is resolved.

Cannot start this animator on a detached view! reveal effect BUG

ANSWER: Cannot start this animator on a detached view! reveal effect

Why I am Getting Error 'Channel is unrecoverably broken and will be disposed!

ANSWER: Why I am Getting Error 'Channel is unrecoverably broken and will be disposed!'

@Override
protected void onPause() {
    super.onPause();
    dismissProgressDialog();

}

private void dismissProgressDialog() {
    if(progressDialog != null && progressDialog.isShowing())
        progressDialog.dismiss();
}
Rosena answered 30/1, 2018 at 1:32 Comment(0)
S
1

I had this issue and the cause was actually a NullPointerException. But it was not presented to me as one!

my Output: screen was stuck for a very long period and ANR

My State : the layout xml file was included another layout, but referenced the included view without giving id in the attached layout. (i had two more similar implementations of the same child view, so the resource id was created with the given name)

Note : it was a Custom Dialog layout, so checking dialogs first may help a bit

Conclusion : There is some memory leak happened on searching the id of the child view.

Supranational answered 25/7, 2018 at 9:14 Comment(0)
H
1

This error occurred in case of memory leak. For example if you have any static context of an Android component (Activity/service/etc) and its gets killed by system.

Example: Music player controls in notification area. Use a foreground service and set actions in the notification channel via PendingIntent like below.

Intent notificationIntent = new Intent(this, MainActivity.class);
        notificationIntent.setAction(AppConstants.ACTION.MAIN_ACTION);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
                notificationIntent, 0);

        Intent previousIntent = new Intent(this, ForegroundService.class);
        previousIntent.setAction(AppConstants.ACTION.PREV_ACTION);
        PendingIntent ppreviousIntent = PendingIntent.getService(this, 0,
                previousIntent, 0);

        Intent playIntent = new Intent(this, ForegroundService.class);
        playIntent.setAction(AppConstants.ACTION.PLAY_ACTION);
        PendingIntent pplayIntent = PendingIntent.getService(this, 0,
                playIntent, 0);

        Intent nextIntent = new Intent(this, ForegroundService.class);
        nextIntent.setAction(AppConstants.ACTION.NEXT_ACTION);

        Bitmap icon = BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_launcher);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_HIGH);

            // Configure the notification channel.
            notificationChannel.setDescription("Channel description");
            notificationChannel.enableLights(true);
            notificationChannel.setLightColor(Color.RED);
            notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
            notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
            notificationChannel.enableVibration(true);
            notificationManager.createNotificationChannel(notificationChannel);
        }

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
        Notification notification = notificationBuilder
                .setOngoing(true)
                .setAutoCancel(true)
                .setWhen(System.currentTimeMillis())
                .setContentTitle("Foreground Service")
                .setContentText("Foreground Service Running")
                .setSmallIcon(R.drawable.ic_launcher)
                .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false))
                .setContentIntent(pendingIntent)
                .setPriority(NotificationManager.IMPORTANCE_MAX)
                .setCategory(Notification.CATEGORY_SERVICE)
                .setTicker("Hearty365")
                .build();
        startForeground(AppConstants.NOTIFICATION_ID.FOREGROUND_SERVICE,
                notification);

And if this notification channel get broken abruptly (may be by system, like in Xiomi devices when we clean out the background apps), then due to memory leaks this error is thrown by system.

Highsounding answered 30/5, 2019 at 20:14 Comment(2)
Hi, I think this could be my problem. I see this error every time I close my media player. I think I clean everything correctly, I hide the notification, unregister receivers etc. But I get this message anyway. The application behavior is not affected by it, but I would like to fix it anyway. What should I do to avoid it?Reareace
@Reareace found anything?Handknit
M
1

For me it was caused by a splash screen image that was too big (over 4000x2000). The problem disappeared after reducing its dimensions.

Mencius answered 21/11, 2019 at 15:49 Comment(0)
N
1

Just Try to Invalidate the IDE cached and restart. This wont fix the issue. But in my case doing this revealed the possible crash

Norford answered 16/5, 2021 at 14:53 Comment(0)
A
1

Please check you Realm entity class.

If you declare variable as lateinit var and you try to check that uninitialized variable check with isNullOrEmpty() return "Channel is unrecoverably broken and will be disposed!"

Anticlinal answered 5/8, 2021 at 12:40 Comment(0)
L
1

In my case I was setting value in background thread viewModelScope.launch(Dispatchers.IO) { } so app was crashing solution in my case I was removed (Dispatchers.IO). viewModelScope.launch{ }

Linguistic answered 4/4, 2022 at 7:7 Comment(1)
Yes. Completely true. This strange "server-channel error" is related to changing Views from another thread. In my case I just wrapped that calls with Handler(Looper.getMainLooper()).post { /*change ui here*/ }Schneider
M
0

In my case, I was using Glide library and the image passed to it was null. So it was throwing this error. I put a check like this:

if (imageData != null) {
    // add value in View here 
}

And it worked fine. Hope this helps someone.

Modality answered 4/1, 2020 at 14:16 Comment(0)
R
0

I got same logcat message, just realize that string.xml value of array cannot be number/digit, but only text/alphabet is allowed.

Rellia answered 8/6, 2020 at 0:23 Comment(0)
K
0

In my case this error is happening because of not connected to firebase firestore but using the same.

To rectify the issue please go to Tools-> Firebase

when a window will open on RHS choose the options to -> Connect your app to Firebase -> Add Cloud Firestore to your app

Kingbolt answered 22/8, 2020 at 7:57 Comment(0)
V
0

Check your ViewModel class and not finding any issue then try to comment code where you using launch or withContext.

In my case, I commented on code where I am using launch or withContext and it worked my app is running normally.

Vase answered 3/3, 2021 at 15:45 Comment(0)
S
0

I had a kind of issue you described. In my case it happened only in release builds. It was caused by the obfuscation: native methods crashed silently on FindClass or GetMethodID call cuz the names were obfuscated. Editing proguard-rules worked out!

Scullion answered 29/9, 2021 at 12:46 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewErr
H
0

The issue for me was I havent defined the instance of an Activity.

Eg:

Myclass my;

onCreate() {

my.getData(); }

Instead of:

Myclass my;

onCreate() {

my = new Myclass(); my.getData(); }

This is weird as Studio has to give some good defining error message.

Housel answered 3/12, 2021 at 12:20 Comment(0)
O
0

Just to add to many other answers:

My app crashed without anything relevant in LogCat. My Retrofit network call that caused the crash looked like this:

CoroutineScope(Dispatchers.IO).launch {
   val response = api.getData()
}

and used the following method signature

suspend fun getData() : Response<RatesResponse>

I changed it removing Response from the return type & got it working 🤷

suspend fun getData() : RatesResponse
Octamerous answered 20/7, 2022 at 20:33 Comment(0)
V
0

There are two ways this can be resolved,

  1. Try removing the Dispatchers.XXX from the launch

    viewModelScope.launch(Dispatchers.IO) { } viewModelScope.launch{ }

  2. Add CoroutineExceptionHandler to catch the exception, this will tell you what exactly is going wrong.

    val handler = CoroutineExceptionHandler { coroutineContext, throwable -> Log.d("TAG","EROR ${throwable.message}") } lifecycleScope.launch(handler) { }

Variegated answered 26/11, 2022 at 19:54 Comment(0)
V
0

When it happened to me:

  1. Forgot to delete TODO().
  2. SQL query result with a null field getting assigned to a non null data class's field.
Vinegar answered 24/1, 2023 at 18:34 Comment(0)
G
0

In my case, I was using Android Volley, to create a high-quality wallpapers app, and when scrolling fast on the grid view the app crashed, and it was a memory issue, I increased the cache of Volley like this:

RequestQueue volleyQueue = Volley.newRequestQueue(this);
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 24 * 1024 * 1024);
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
volleyQueue.start();

The issue was fixed

another way to fix it is to use no cache like this:

RequestQueue volleyQueue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack()));
Gloxinia answered 2/10, 2023 at 9:54 Comment(0)
P
0

I had the same problem "Channel is unrecoverably broken and will be disposed!" I followed all the practice proposed in above answers but nothing. As my app was a book with 4 chapters and it didn't work only after the third, I decided to copy the Java class of the chapter 3 in the chapter 4 and it worked. How I'm using webview to fetch text I tried to substitute each text part of the chapter 3 with those of chapter 4 and testing it at each part changed. There was no chance to get one part into because it always broken the app. By the end I supposed that the quantity of line text could be too much. So I shortened the text length moving part of the text in the next section and the app ran smoothly. I am assumed that there's a limit ot text lines of characters that can be included in a webview. I wish can be useful for others.

Publisher answered 23/4 at 11:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.