Skip to content

[BUG] apktool-lib tests fail on headless server #3997

@gramound

Description

@gramound

Information

  1. Source Version - https://github.com/iBotPeaches/Apktool main branch addfcdc
  2. Operating System - Ubuntu 22.04.5 LTS (server)
  3. Java Version (java --version) - openjdk 21.0.8

Log

> Task :brut.apktool:apktool-lib:test

brut.androlib.BuildAndDecodeApkTest > classMethod FAILED
    java.awt.AWTError at BuildAndDecodeApkTest.java:53

brut.androlib.LargeIntsInManifestTest > checkIfLargeIntsAreHandledTest FAILED
    java.lang.NoClassDefFoundError at LargeIntsInManifestTest.java:40
        Caused by: java.lang.ExceptionInInitializerError at X11GraphicsEnvironment.java:-2

brut.androlib.ProtectedChunksTest > checkIfDecodeWorksWithoutCrash FAILED
    java.lang.NoClassDefFoundError at ProtectedChunksTest.java:39
        Caused by: java.lang.ExceptionInInitializerError at X11GraphicsEnvironment.java:-2

brut.androlib.SkipAssetTest > checkControl FAILED
    java.lang.NoClassDefFoundError at SkipAssetTest.java:55
        Caused by: java.lang.ExceptionInInitializerError at X11GraphicsEnvironment.java:-2

brut.androlib.SkipAssetTest > checkIfEnablingSkipAssetWorks FAILED
    java.lang.NoClassDefFoundError at SkipAssetTest.java:42
        Caused by: java.lang.ExceptionInInitializerError at X11GraphicsEnvironment.java:-2

106 tests completed, 5 failed

> Task :brut.apktool:apktool-lib:test FAILED

Steps to Reproduce

  1. ./gradlew build shadowJar proguard

Suggested fix

Sorry I can't make a pull request. Please consider doing this:

$ git diff
diff --git a/brut.apktool/apktool-lib/build.gradle.kts b/brut.apktool/apktool-lib/build.gradle.kts
index 4c1916d1..08892ae2 100644
--- a/brut.apktool/apktool-lib/build.gradle.kts
+++ b/brut.apktool/apktool-lib/build.gradle.kts
@@ -30,5 +30,9 @@ tasks {
         // Increases validation of extra field of zip header. Some older Android apps
         // used this field to store data violating the zip specification.
         systemProperty("jdk.util.zip.disableZip64ExtraFieldValidation", true)
+
+        // Fix for AWT/X11 graphics environment issues in headless environments
+        // Required for tests that use ImageIO operations (nine-patch processing, etc.)
+        systemProperty("java.awt.headless", true)
     }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions