Blank (empty?) app when building for Android

Hey all, I’ve been struggling to get my app to run correctly when building for Android and nothing I’ve found on the forums/the internet at large so far has solved my problem.

My app works fine in the browser, and even when running with npx cap run android (of course in this case it’s streaming files from my dev machine), but when I create a build – whether debug or release – or run the project from android studio, it seems to produce a totally empty app. When attaching with the chrome remote inspector, localhost seems to just be capacitor shim code and none of my files appear to be included. The APK is also very tiny, under 2mb, which seems unrealistic.

Debug log
07/29 14:18:13: Launching 'app' on Google Pixel 3.
Install successfully finished in 1 s 976 ms.
$ adb shell am start -n "com.jacobalbano.moyase/com.jacobalbano.moyase.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.jacobalbano.moyase | com.jacobalbano.moyase.test
Waiting for application to come online: com.jacobalbano.moyase | com.jacobalbano.moyase.test
Connected to process 18776 on device 'google-pixel_3-8BFX19SG4'.
Connecting to com.jacobalbano.moyase
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/obalbano.moyas: Late-enabling -Xcheck:jni
I/obalbano.moyas: Unquickening 12 vdex files!
W/ActivityThread: Application com.jacobalbano.moyase is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/System.out: Debugger has connected
    waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:55280', transport: 'socket'
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/chatty: uid=10333(com.jacobalbano.moyase) identical 1 line
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1329)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
E/obalbano.moyas: Invalid ID 0x00000000.
W/obalbano.moyas: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/obalbano.moyas: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
I/WebViewFactory: Loading com.google.android.webview version 92.0.4515.115 (code 451511533)
W/obalbano.moyas: Accessing hidden method Landroid/os/Trace;->isTagEnabled(J)Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/os/Trace;->traceBegin(JLjava/lang/String;)V (greylist, reflection, allowed)
    Accessing hidden method Landroid/os/Trace;->traceEnd(J)V (greylist, reflection, allowed)
    Accessing hidden method Landroid/os/Trace;->asyncTraceBegin(JLjava/lang/String;I)V (greylist, reflection, allowed)
    Accessing hidden method Landroid/os/Trace;->asyncTraceEnd(JLjava/lang/String;I)V (greylist, reflection, allowed)
I/cr_WVCFactoryProvider: Loaded version=92.0.4515.115 minSdkVersion=29 isBundle=true multiprocess=true packageId=2
E/obalbano.moyas: Invalid ID 0x00000000.
E/obalbano.moyas: Invalid ID 0x00000000.
I/cr_LibraryLoader: Successfully loaded native library
I/cr_CachingUmaRecorder: Flushed 8 samples from 8 histograms.
I/TetheringManager: registerTetheringEventCallback:com.jacobalbano.moyase
W/chromium: [WARNING:dns_config_service_android.cc(153)] Failed to read DnsConfig.
D/Capacitor: Starting BridgeActivity
D/Capacitor: Registering plugin: WebView
D/Capacitor: Registering plugin: App
D/Capacitor: Registering plugin: Haptics
D/Capacitor: Registering plugin: Keyboard
D/Capacitor: Registering plugin: StatusBar
E/Capacitor: Unable to read file at path public/plugins
D/Capacitor: Loading app at http://localhost
W/obalbano.moyas: Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (greylist, reflection, allowed)
I/AdrenoGLES-0: QUALCOMM build                   : 781e7d0, I46ff5fc46f
    Build Date                       : 12/01/20
    OpenGL ES Shader Compiler Version: EV031.31.04.01
    Local Branch                     : QPR1
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
    Build Config                     : C P 11.0.1 AArch64
    Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
W/cr_media: Requires BLUETOOTH permission
I/AdrenoGLES-0: PFP: 0x016ee189, ME: 0x00000000
D/Capacitor: App started
W/AdrenoUtils: <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
    <ReadGpuID:221>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
D/Capacitor/AppPlugin: Firing change: true
V/Capacitor/AppPlugin: Notifying listeners for event appStateChange
D/Capacitor/AppPlugin: No listeners found for event appStateChange
D/Capacitor: App resumed
D/Capacitor: Handling local request: http://localhost/
I/Gralloc4: mapper 4.x is not supported
W/Gralloc3: mapper 3.x is not supported
E/libc: Access denied finding property "vendor.gralloc.disable_ahardware_buffer"
D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png

One error that seems relevant to me is “E/Capacitor: Unable to read file at path public/plugins”, but I don’t know how to address this (and also it says immediately before that the plugins are being registered so in theory it should be working already).

The github repo is here if anyone wants to take a look. The /android/ folder isn’t checked in but my steps to initialize that are literally just

npx cap add android
npx cap open android

so if there’s extra configuration I need to do there, I’m all ears (though I bet I’ve already tried it at some point).

System details (output of "ionic info")

Ionic:

Ionic CLI : 6.16.3 (C:\Users\Jake\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/vue 5.6.11

Capacitor:

Capacitor CLI : 3.0.2
@capacitor/android : 3.1.2
@capacitor/core : 3.1.1
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run : 1.4.0

System:

NodeJS : v14.17.3 (C:\Program Files\nodejs\node.exe)
npm : 6.14.13
OS : Windows 10

I’d be grateful for any help you can give!

Hi
Maybe not a solution but: maybe try do all this with a simple starter app without all the packages? So u can see if the flow to apk build breaks even then?

Hey, thanks for the reply. The starter “tabs” project works fine, and if I look at the output I can even see that the errors I had noticed in the log are there as well. The notable difference is that the sample app has a bunch of lines like

D/Capacitor: Handling local request: http://localhost/js/chunk-53b1137a.c087f733.js

whereas my real app “handles” localhost and favicon, and then nothing else.

I don’t know a lot about the android platform but one thing I did consider was whether I needed some special permissions for storage (I’m just using the @ionic/storage package with the default options). However, stubbing out my storage layer doesn’t seem to make a difference, and after installing the storage package to the tabs project it still works fine.

Comparing the two projects side by side doesn’t yield anything likely. My project is pretty lightweight; just a handful of views and a few helper classes. I started it about a month ago with the blank template and converted it to javascript, so most of the differences are just from the difference in language alone.

Ok, well my strategy then would be to rebuild the app from scratch - step by step - while testing if it still works

If I cant find the issue in what is broken I generally start from from whatever is working

Ps. Sometimes some creepy things happen in node-modules killing the app. Very hard to find and only to solve doing some sort of rebuilt

Rebuilding from scratch feels like a last resort honestly…is there anything I can do to pinpoint the issue? I’m sure there’s some process I can use to find out where it’s failing but since I’m an ionic noob I just don’t know what it is. If this app was a lot bigger I probably wouldn’t have the option to reassemble it piecemeal.

This is going to be hell for you or any developer to figure out your problem. But here are several options you can try that I used when I encountered a similar issue. but it’s going to take some time.

  • Run the project in android studio and look at the log to see if any errors show.
  • Go through each plugin and remove and run the app to find out which is giving you the error. If it’s not that one, then re add it back and repeat process until you went through all.
  • Remove the Android platform and plugins folder then re-add.
  • Remove node modules and re-add.

What Tom said is your best bet honestly. Good luck.

Thanks for the reply. The only thing on your list I hadn’t done was to remove and re-add node modules, so I gave it a try. It didn’t solve my problem directly but since I had to re-initialize capacitor I found that the config file had its webDir property set to “public”, which should be “dist” for Vue apps. I changed that property, synced the project, and it worked right away.

U luckiest person of the day!

1 Like

In case anyone finds this topic while trying to solve a similar problem, make sure your capacitor.config.json file has its webDir property set correctly.

According to this page it should ask you in the questionnaire, but it didn’t do so for me. This documentation seems to be out of date since my config file is a json not a ts.

Last, it will ask what directory your web assets get built into. For Angular, this is www , React is build , and Vue is dist . If you don’t know right now, you can update this value in the capacitor.config.ts file later.

This also solved the problem of my apk being super tiny; it’s now around 5mb which is much more in line with what I would have expected.

Thanks everyone for your help.

2 Likes

Yeah, those docs are wrong, now it tries to guess the webDir folder based on the frameworks you use instead of asking, so if it didn’t work for you, can you report an issue and provide a sample app so it can be fixed?