dodorare / crossbow

Cross-Platform build tools and toolkit for games and game engines written in Rust! 🦀
https://crossbow.dodorare.com/
Apache License 2.0
198 stars 13 forks source link

macroquad application cannot use the whole screen in Android #71

Closed beling closed 2 years ago

beling commented 2 years ago

The macroquad application build with crossbundle (under linux) do not use whole screen. I have unused black area: at the bottom of the screen in portrait mode, at the left and the right sides in landscape mode.

I have fullscreen: true in my macroquad windows conf, but this flag does not change anything under android.

enfipy commented 2 years ago

Thank you for the issue.

Can you provide your AndroidManifest.xml or/and Cargo.toml?

Perhaps you need to set android:theme in the manifest file as shown here: https://stackoverflow.com/a/5752646.

In our android-manifest-rs - https://github.com/dodorare/android-manifest-rs/blob/main/src/application.rs#L621.

beling commented 2 years ago

My Cargo.toml:

[package]
name = "pipes-player"
version = "0.1.0"
edition = "2021"

[dependencies]
macroquad = "=0.3.10"
tiny-skia = "0.6"
fastrand = "1.*"
crossbow = { git = "https://github.com/dodorare/crossbow" }

[features]
dyn_load_assets = []

[package.metadata]
app_name = "Pipes"
target_sdk_version = 30
version_code = "1"
icon = "ic_launcher"

android_build_targets = ["aarch64-linux-android", "armv7-linux-androideabi", "i686-linux-android"]
android_assets = "assets"
android_res = "res/android"

The manifest generated by crossbow:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.rust.pipes_player" android:versionCode="1" android:versionName="0.1.0">
  <application android:debuggable="false" android:hasCode="false" android:icon="@mipmap/ic_launcher" android:label="Pipes" android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
    <activity android:configChanges="orientation|keyboardHidden|screenSize" android:label="Pipes" android:name="android.app.NativeActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="android.app.lib_name" android:value="pipes_player" />
    </activity>
  </application>
  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="30" />
  <uses-feature android:required="true" android:glEsVersion="0x00030002" />
</manifest>

Compiled APK: http://pipes.w8.pl/download/Pipes.apk

I have already tried to changed the theme to @android:style/Theme.NoTitleBar.Fullscreen in the manifest but I couldn't force crossbow to use my manifest during compilation (see issue #70 ).

beling commented 2 years ago

And this is the manifest generated by quad-apk:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="rust.pipes_player"
        android:versionCode="1"
        android:versionName="0.1.0">
    <uses-sdk android:targetSdkVersion="29" android:minSdkVersion="18" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true"></uses-feature>
    <application 
            android:hasCode="false" android:label="pipes-player" >
        <activity 
                android:name="android.app.NativeActivity"
                android:label="pipes-player"
                android:configChanges="orientation|keyboardHidden|screenSize"  >
            <meta-data android:name="android.app.lib_name" android:value="pipes-player" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

However, I am not able to compile working copy of my project with quad-apk. Compilation ends successfully, but the program immediately crashes at start. So I do not know if quad-apk generates usefull manifest.

beling commented 2 years ago

After fixing some settings in Cargo.toml, now I have working version built with quad-apk that uses whole screen. It uses the following manifest generated by quad-apk:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="rust.pipes"
        android:versionCode="1"
        android:versionName="0.1.0">
    <uses-sdk android:targetSdkVersion="30" android:minSdkVersion="18" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true"></uses-feature>
    <application 
            android:hasCode="false" android:label="Pipes"
            android:icon="@mipmap/ic_launcher"
            android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen" >
        <activity 
                android:name="android.app.NativeActivity"
                android:label="Pipes"
                android:configChanges="orientation|keyboardHidden|screenSize"  >
            <meta-data android:name="android.app.lib_name" android:value="pipes-player" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
beling commented 2 years ago

Links to APKs: quad-apk http://pipes.w8.pl/download/Pipes_quad.apk crossbow http://pipes.w8.pl/download/Pipes_crossbow.apk

enfipy commented 2 years ago

I can confirm this is a bug, but we couldn't find where it is yet. It looks like there's no problem with the AndroidManifest.xml files (we analyzed your and our apks built by crossbundle and quad-apk - and haven't found anything wrong). We will investigate and fix this issue as soon as possible.

comcloudway commented 2 years ago

I'm also experiencing this problem, and wasn't able to fix it by adjusting the Manifest.

The way I could fix it is by first using crossbundle run android to build the library and then running ´cargo apk run --help´ (this works, because --help stops cargo-apk from building the library.

So I suspect, that maybe the base apk is faulty?

comcloudway commented 2 years ago

Ok I've found a better workaround, that works, when only using crossbundle.

Simply add android:resizeableActivity="true" to the activity section in the Android Manifest.

 <activity
    android:name="android.app.NativeActivity"
    android:label="Pipes"
    android:resizeableActivity="true"
    android:configChanges="orientation|keyboardHidden|screenSize"  >

The following Manifest works for me, in my template repository:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.rust.egui_macroquad_template"
        android:versionCode="1"
        android:compileSdkVersion="29"
        android:compileSdkVersionCodename="10"
        android:versionName="0.1.0"
        platformBuildVersionCode="29"
        platformBuildVersionName="10">
    <uses-sdk android:targetSdkVersion="29" android:minSdkVersion="23" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true"></uses-feature>
    <application
            android:hasCode="false" android:label="Egui Macroquad Template"
            android:icon="@mipmap/ic_launcher"
            >
        <activity
                android:name="android.app.NativeActivity"
                android:label="Egui Macroquad Template"
                android:resizeableActivity="true"
                android:configChanges="orientation|keyboardHidden|screenSize"  >
            <meta-data android:name="android.app.lib_name" android:value="egui_macroquad_template" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>```

EDIT: Updated the Manifest example & added xml block for the Pipes application