Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] getShowProgress true makes app force quit at launch #43

Open
jbrieu opened this issue Jun 28, 2016 · 1 comment
Open

[Android] getShowProgress true makes app force quit at launch #43

jbrieu opened this issue Jun 28, 2016 · 1 comment

Comments

@jbrieu
Copy link

jbrieu commented Jun 28, 2016

java.lang.RuntimeException: An error occurred while executing doInBackground()
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.os.AsyncTask$3.done(AsyncTask.java:309)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)
06-28 23:50:20.535  3571  3588 E AndroidRuntime: Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.os.Handler.<init>(Handler.java:200)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.os.Handler.<init>(Handler.java:114)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.widget.Toast$TN.<init>(Toast.java:345)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.widget.Toast.<init>(Toast.java:101)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.widget.Toast.makeText(Toast.java:259)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.widget.Toast.makeText(Toast.java:286)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater.showProgressToast(ReactNativeAutoUpdater.java:265)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater.access$200(ReactNativeAutoUpdater.java:26)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater$FetchMetadataTask.doInBackground(ReactNativeAutoUpdater.java:292)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater$FetchMetadataTask.doInBackground(ReactNativeAutoUpdater.java:270)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at android.os.AsyncTask$2.call(AsyncTask.java:295)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-28 23:50:20.535  3571  3588 E AndroidRuntime:    ... 4 more

@yag00
Copy link

yag00 commented Sep 14, 2016

Error is caused by Toast :how to fix on stackoverflow

patch ReactNativeAutoUpdater.java with :

private final Handler handler = new Handler() {
  public void handleMessage(Message msg) {
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, msg.arg1, duration);
    toast.show();
  }
};

private void showProgressToast(int message) {
    if (this.showProgress) {
        Message msg = handler.obtainMessage();
        msg.arg1 = message;
        handler.sendMessage(msg);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants