Problem with Android API 27 and later


#1

With Android API 27 and later, you can no longer specify screen orientation in the manifest file:

android:screenOrientation="portrait"

if you have a style setting of:

<item name="android:windowIsTranslucent">true</item>

Instead, you need to request the desired screen orientation in the onCreate method of the main activity:

        if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

Otherwise, your app will not run.

I need to figure out how to get the above code snippet inserted into the main activity java file as part of a ‘uno build …’ process. Does anyone know where I need to start looking in order to figure out how to do this?

AC


#3

Hello! Is this the same issue as this:


#4

Hi,

We experienced the same issue a few weeks ago after making a new release for the production environment. We couldn’t find any solution in the forums and we had to fix it immediately. Since we are catching the errors through Raygun, we identified the source of the error in Java code. And the only way we could find to fix the problem was to make the necessary changes in the source code, generated by Fuse, using Android Studio and then packaged the app again using Android Studio.

It was an easy problem to fix without understanding anything about Java or Android development :slight_smile: However, I don’t think we will be that lucky next time!

We have invested a lot in our app developed by Fuse but unfortunately, we might have to accept the fact that it’s dying.


#5

Hello ipek! Good thing that you found the solution, but could you share it with us? The reason why open source communities are dying is because people are not sharing their work and solutions to common problems. :slightly_smiling_face:


#6

Hi Matti,

As acoad mentioned the problem was because of this following line:
<item name="android:windowIsTranslucent">true</item>

Since there was no way of us being able to integrate the removal of this line during theuno build process, we installed Android Studio, found the line and removed it. And luckily, we didn’t face any problems that we couldn’t solve when we hit build in Android Studio. Basically, we are now dependant on Android Studio to make the build and packaging. This was what I advised acoad to do, if, in case, he can’t find any other solution.

Believe me, if I had a better solution I would be happy to share it with the community. I can not call mine a solid solution, it was just bypassing the problem. Now I have to make a new release and shouldn’t forget to remove this line for Android :slight_smile:


#7

Thanks for the clarification!