korlibs / korge

KorGE Game Engine. Multiplatform Kotlin Game Engine
https://korge.org/
Other
2.57k stars 125 forks source link

Android `processReleaseResources` fails #2268

Closed gmitch215 closed 3 months ago

gmitch215 commented 4 months ago

The link resources task from the Android plugin fails from the generated Android Manifest.

> Task :processReleaseResources FAILED                                                                                                                                                                                             

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:7:2-31:16: AAPT: error: resource mipmap/icon (aka xyz.calcugames.combinatory:mipmap/icon) not found.

     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:7:2-31:16: AAPT: error: resource style/AppThemeOverride (aka xyz.calcugames.combinatory:style/AppThemeOverride) not found.

     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_banner (aka xyz.calcugames.combinatory:drawable/app_banner) not found.

     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_icon (aka xyz.calcugames.combinatory:drawable/app_icon) not found.

Tested on v5.4.0 and v6.0.0-alpha9.

It seems to pass when androidMinSdk is set to 33, but the minimum SDK needs to be lower than that for my application. If it's supposed to be like that, can you make it the default?

soywiz commented 4 months ago

Hi. Thanks for reporting. How can I reproduce it?

Would this fix the issue? https://github.com/korlibs/korge/pull/2004

gmitch215 commented 4 months ago

Doesn't seem like it.

To reproduce, I just run gradlew clean packageRelease with a medium-sized KorGE project, using targetAndroid. I'm using things like userHomeVfs, multiple scenes, and many other things. I set the version to 999.0.0.999 after cloning and running gradlew publishToMavenLocal as specified in the README.md

Here's a more detailed report I got from --info:

plugins {
    id("com.soywiz.korge") version "999.0.0.999"
}

val app = "MyGame"
val desc = "Dummy description"

korge {
    id = group.toString()
    version = rootProject.version.toString()
    exeBaseName = app
    name = app
    description = desc
    orientation = Orientation.PORTRAIT
    icon = file("assets/icon.png")
    banner = file("assets/banner.png")

    entryPoint = "my.custom.package.main"
    jvmMainClassName = "my.custom.package.MainKt"

    targetJvm()
    targetAndroid()

    if (Os.isFamily(Os.FAMILY_MAC))
        targetIos()
}
> Task :jvmProcessResources
Caching disabled for task ':jvmProcessResources' because:
  Not worth caching
Task ':jvmProcessResources' is not up-to-date because:
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\assets has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\assets\banner.png has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\assets\icon.png has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\assets\icons has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\assets\level has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\assets\sfx has been removed.
  Output property 'destinationDir' file D:\gmitch215\...\build\processedResources\jvm\main\font has been removed.
file or directory 'D:\gmitch215\...\src\jvmMain\resources', not found
Resolve mutations for :generateReleaseAssets (Thread[#835,Execution worker Thread 9,5,main]) started.
:generateReleaseAssets (Thread[#835,Execution worker Thread 9,5,main]) started.

> Task :generateReleaseAssets
Skipping task ':generateReleaseAssets' as it has no actions.
Resolve mutations for :releaseAssetsCopyForAGP (Thread[#835,Execution worker Thread 9,5,main]) started.
:releaseAssetsCopyForAGP (Thread[#835,Execution worker Thread 9,5,main]) started.

> Task :releaseAssetsCopyForAGP NO-SOURCE
Skipping task ':releaseAssetsCopyForAGP' as it has no source files and no previous output files.
Resolve mutations for :mergeReleaseAssets (Thread[#835,Execution worker Thread 9,5,main]) started.
:mergeReleaseAssets (Thread[#835,Execution worker Thread 9,5,main]) started.

> Task :processReleaseResources FAILED
Transforming aapt2-8.2.0-10154469-windows.jar (com.android.tools.build:aapt2:8.2.0-10154469) with Aapt2Extractor
Transforming korge-release.aar (com.soywiz.korge:korge-android:999.0.0.999) with ExtractAarTransform
Transforming korge-release.aar (com.soywiz.korge:korge-android:999.0.0.999) with AarResourcesCompilerTransform
Transforming korge-core-release.aar (com.soywiz.korge:korge-core-android:999.0.0.999) with ExtractAarTransform
Transforming korge-core-release.aar (com.soywiz.korge:korge-core-android:999.0.0.999) with AarResourcesCompilerTransform
Transforming korlibs-all-release.aar (com.soywiz:korlibs-all-android:6.0.0-alpha9) with ExtractAarTransform
Transforming korlibs-all-release.aar (com.soywiz:korlibs-all-android:6.0.0-alpha9) with AarResourcesCompilerTransform
Transforming calculatory-release.aar (xyz.calcugames.combinatory:calculatory-android:0.3.5) with ExtractAarTransform
Transforming calculatory-release.aar (xyz.calcugames.combinatory:calculatory-android:0.3.5) with AarResourcesCompilerTransform
Transforming korge-release.aar (com.soywiz.korge:korge-android:999.0.0.999) with ExtractAarTransform
Transforming korge-release.aar (com.soywiz.korge:korge-android:999.0.0.999) with LibrarySymbolTableTransform
Transforming korge-core-release.aar (com.soywiz.korge:korge-core-android:999.0.0.999) with ExtractAarTransform
Transforming korge-core-release.aar (com.soywiz.korge:korge-core-android:999.0.0.999) with LibrarySymbolTableTransform
Transforming korlibs-all-release.aar (com.soywiz:korlibs-all-android:6.0.0-alpha9) with ExtractAarTransform
Transforming korlibs-all-release.aar (com.soywiz:korlibs-all-android:6.0.0-alpha9) with LibrarySymbolTableTransform
Build cache key for task ':processReleaseResources' is b6f7c04b643adad6f0a5f260141ab5c1
Task ':processReleaseResources' is not up-to-date because:
  Task has failed previously.
The input changes require a full rebuild for incremental task ':processReleaseResources'.
AAPT2 aapt2-8.2.0-10154469-windows Daemon #0: starting
Android resource linking failed:
process = AAPT2 aapt2-8.2.0-10154469-windows Daemon #0:
command = D:\local-gradle\caches\transforms-4\ebb81a9674a162759a537caf59b5dfa5\transformed\aapt2-8.2.0-10154469-windows\aapt2.exe link -I\
        D:\Programs\Android\SDK\platforms\android-33\android.jar\
        --manifest\
        D:\gmitch215\...\build\intermediates\packaged_manifests\release\AndroidManifest.xml\
        -o\
        D:\gmitch215\...\build\intermediates\processed_res\release\out\resources-release.ap_\
        -R\
        @D:\gmitch215\...\build\intermediates\incremental\processReleaseResources\resources-list-for-resources-release.ap_.txt\
        --auto-add-overlay\
        --proguard\
        D:\gmitch215\...\build\intermediates\aapt_proguard_file\release\aapt_rules.txt\
        --custom-package\
        my.custom.package\
        -0\
        apk\
        --output-text-symbols\
        D:\gmitch215\...\build\intermediates\runtime_symbol_list\release\R.txt\
        --no-version-vectors\
        --proguard-minimal-keep-rules\
        --no-proguard-location-reference\
        --emit-ids\
        D:\gmitch215\...\build\intermediates\stable_resource_ids_file\release\stableIds.txt

> Task :mergeReleaseAssets FROM-CACHE
Transforming korge-release.aar (com.soywiz.korge:korge-android:999.0.0.999) with ExtractAarTransform
Transforming korge-release.aar (com.soywiz.korge:korge-android:999.0.0.999) with AarTransform
Transforming korge-core-release.aar (com.soywiz.korge:korge-core-android:999.0.0.999) with ExtractAarTransform
Transforming korge-core-release.aar (com.soywiz.korge:korge-core-android:999.0.0.999) with AarTransform
Transforming korlibs-all-release.aar (com.soywiz:korlibs-all-android:6.0.0-alpha9) with ExtractAarTransform
Transforming korlibs-all-release.aar (com.soywiz:korlibs-all-android:6.0.0-alpha9) with AarTransform
Build cache key for task ':mergeReleaseAssets' is 334b82b897d8f381fa1d85b6204244a1
Task ':mergeReleaseAssets' is not up-to-date because:
  Output property 'outputDir' file D:\gmitch215\...\build\intermediates\assets\release has been removed.
  Output property 'outputDir' file D:\gmitch215\...\build\intermediates\assets\release\$catalog.json has been removed.
  Output property 'outputDir' file D:\gmitch215\...\build\intermediates\assets\release\assets has been removed.
  Output property 'outputDir' file D:\gmitch215\...\build\intermediates\assets\release\font has been removed.
  Output property 'outputDir' file D:\gmitch215\...\build\intermediates\assets\release\META-INF has been removed.
Loaded cache entry for task ':mergeReleaseAssets' with cache key 334b82b897d8f381fa1d85b6204244a1
AAPT2 aapt2-8.2.0-10154469-windows Daemon #0: shutdown

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:7:2-31:16: AAPT: error: resource mipmap/icon (aka my.custom.package:mipmap/icon) not found.

     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:7:2-31:16: AAPT: error: resource style/AppThemeOverride (aka my.custom.package:style/AppThemeOverride) not found.

     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_banner (aka my.custom.package:drawable/app_banner) not found.

     ERROR: D:\gmitch215\...\build\AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_icon (aka my.custom.package:drawable/app_icon) not found.
gmitch215 commented 4 months ago

@soywiz Any updates?

soywiz commented 4 months ago

Is the repo available so I can check? Otherwise, could you provide the generated AndroidManifest.xml, build.gradle.kts, settings.gradle.kts, gradle.properties, gradle/libs.versions.toml files?

gmitch215 commented 4 months ago

I tried recreating it on my Macbook, but it seems to pass now. I'll see if it still has an issue on my windows desktop.

gmitch215 commented 3 months ago

Seems to work in 6.0.0-beta1.