Home > Software engineering >  Android Studio - blank white screen when running Ionic App on an emulator
Android Studio - blank white screen when running Ionic App on an emulator

Time:04-20

I'm working on an Ionic App.

It's running fine both in iOS emulator (via Xcode) and via ionic serve, but when trying to run it on an android emulator in Android Studio, the following happens:

  1. The Emulator launches successfully and the android OS is shown and responsive.
  2. When launching the app, it's ended up in a blank white screen.

I've read on many solutions like this Android studio emulator white screen, but none of them was working for me.

I've also tried to reinstall android studio, only to end up with the same result. This is how I'm triggering the android studio IDE:

Building the Ionic app ==> ionic build

Running Android Studio ==> npx cap open android

Below is my MainActivity.java file:

package com.batsir.ben;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

import ch.byrds.capacitor.contacts.Contacts;

public class MainActivity extends BridgeActivity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            
        this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{          
          add(Contacts.class);
        }});
     }
}

Here are some errors I was able to see when running the app from Logcat:

2022-04-05 20:40:19.181 1591-1591/? E/studio.deploy: MessagePipeWrapper: Cannot write (EOF)
2022-04-05 20:40:19.181 1591-1591/? E/studio.deploy: Unable to write magic number to pipe
2022-04-05 20:40:19.200 1591-1591/? E/studio.deploy: MessagePipeWrapper: Cannot read (EOF)
2022-04-05 20:40:19.201 1591-1591/? E/studio.deploy: MessagePipeWrapper: Unable to read magic number (received= '
2022-04-05 20:40:19.201 1591-1591/? E/studio.deploy: Protopipe: Unable to read() from pipe
2022-04-05 20:40:19.343 3306-3306/? E/studio.deploy: Could not remove dir '/data/data/com.batsir.ben/code_cache/.ll/': No such file or directory
2022-04-05 20:40:22.220 3322-3322/com.batsir.ben E/com.batsir.ben: Invalid ID 0x00000000.
2022-04-05 20:40:22.542 3322-3322/com.batsir.ben E/com.batsir.ben: Invalid ID 0x00000000.
2022-04-05 20:40:22.543 3322-3322/com.batsir.ben E/com.batsir.ben: Invalid ID 0x00000000.
2022-04-05 20:40:23.486 395-429/? E/HWComposer: getSupportedContentTypes: getSupportedContentTypes failed for display 4619827259835644672: Unsupported (8)
2022-04-05 20:40:24.526 3322-3387/com.batsir.ben E/Capacitor: Unable to open asset URL: http://localhost/<%= BASE_URL %>assets/icon/favicon.png
2022-04-05 20:40:24.532 3322-3387/com.batsir.ben E/Capacitor: Unable to open asset URL: http://localhost/<%= BASE_URL %>assets/icon/favicon.png
2022-04-05 20:40:24.541 3322-3387/com.batsir.ben E/Capacitor: Unable to open asset URL: http://localhost/<%= BASE_URL %>assets/icon/favicon.png

Please help me understand what am I missing.

UPDATE:

after debugging with chrome debugger (chrome://inspect/#devices): I see the only error I get is:

Failed to load resource: the server responded with a status of 404 (OK) http://localhost/<%= BASE_URL %>assets/icon/favicon.png

UPDATE #2:

I was able to get rid of the error mentioned above after handling founding and fixing this line in inedx.html:

<link rel="shortcut icon" type="image/png" href="assets/icon/favicon.png" />

so now, there's no error but the outcome is sill the same - only blank white screen.

CodePudding user response:

For whoever meets the same issue.

It turns out that my problem was the path where ionic build builds the project (dist) and the webDir path on my capacitor.config.json (public) weren't matched.

After syncing them the app was running just fine

  • Related