@capacitor/screen-orientation not working on Android

Using @capacitor/screen-orientation 5.0.7 with the listener “screenOrientationChange” works fine on iOS but not on Android. Any ideas why?

Android stays in portrait and does not display the console log “Orientation changed”.

ScreenOrientationCap.addListener('screenOrientationChange', (event) => {
      console.log('Orientation changed:', event);

      if (event.type === 'landscape-primary' || event.type === 'landscape-secondary') {
        this.landscapeOrientation = true;
      } else {
        this.landscapeOrientation = false;

It seems to add the listener fine:

I had the same issue, switched to: Capacitor Screen Orientation Plugin - Capawesome, works great!


Thanks I will give it a try. I logged an issue here: @capacitor/screen-orientation not working on Android · Issue #2132 · ionic-team/capacitor-plugins · GitHub

The event only fires if the app screen rotates, if it’s not rotating something is blocking the rotation.

Did you use the plugin’s lock method? in that case, call unlock to allow rotation.

If that doesn’t solve the issue, maybe you have the rotation locked for your device?

1 Like

I don’t have the auto-rotate locked on the device but it turns out I did lock it in portrait using
import { ScreenOrientation } from ‘@ionic-native/screen-orientation/ngx’;

Because this worked on iOS I just assumed it would also work on Android.
Mystery solved!