korlibs / korge

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

The generated hello-world-korge temptate is not able to build #2283

Open soywiz opened 3 weeks ago

soywiz commented 3 weeks ago

Discussed in https://github.com/korlibs/korge/discussions/2280

Originally posted by **AShynkevich** August 23, 2024 Once I've run the Korge IDE, I tried to create simple hello-world-project: image After the project initialized/indexed all necessary stuff I disabled the targets, and left only two: targetJvm() & targetAndroid() image Then I try to run the project manually via main.kt image and get image Then I try to build via gradle: `./gradlew clean build` But get: ``` Configuration cache state could not be cached: field `__compileLintModelMetadataFileCollection__` of `com.android.build.gradle.internal.lint.JavaArtifactInput` bean found in field `__testArtifact__` of `com.android.build.gradle.internal.lint.VariantInputs` bean found in field `__variantInputs__` of task `:deps:generateReleaseLintModel` of type `com.android.build.gradle.internal.lint.LintModelWriterTask`: error writing value of type 'org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection' > Could not resolve all files for configuration ':deps:releaseUnitTestCompileClasspath'. > Could not resolve org.jetbrains.kotlin:kotlin-test:2.0.0. Required by: project :deps > Unable to find a variant of org.jetbrains.kotlin:kotlin-test:2.0.0 providing the requested capability org.jetbrains.kotlin:kotlin-test-framework-junit: - Variant compile provides org.jetbrains.kotlin:kotlin-test:2.0.0 - Variant enforced-platform-compile provides org.jetbrains.kotlin:kotlin-test-derived-enforced-platform:2.0.0 - Variant enforced-platform-runtime provides org.jetbrains.kotlin:kotlin-test-derived-enforced-platform:2.0.0 - Variant javadoc provides org.jetbrains.kotlin:kotlin-test:2.0.0 - Variant platform-compile provides org.jetbrains.kotlin:kotlin-test-derived-platform:2.0.0 - Variant platform-runtime provides org.jetbrains.kotlin:kotlin-test-derived-platform:2.0.0 - Variant runtime provides org.jetbrains.kotlin:kotlin-test:2.0.0 - Variant sources provides org.jetbrains.kotlin:kotlin-test:2.0.0 * Try: > Review the variant matching algorithm at https://docs.gradle.org/8.8/userguide/variant_attributes.html#sec:abm_algorithm. > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ``` Is it supposed to be or I can fix it somehow via **korge** plugin? The **hello-world** project I pushed here: https://github.com/AShynkevich/korge-test
AShynkevich commented 3 weeks ago

As I see you've already created the issue from the discusstion, thanks for that :)

For this problem. Could you try to comment or remove these lines: https://github.com/AShynkevich/korge-test/blob/master/gradle.properties#L6-L7 Also try to set https://github.com/AShynkevich/korge-test/blob/master/gradle/libs.versions.toml#L2 to korge = { id = "com.soywiz.korge", version = "6.0.0-beta2" }

I did it (push it) and have another error after build:

./gradlew clean build

* What went wrong:
Execution failed for task ':processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:7:2-31:16: AAPT: error: resource mipmap/icon (aka com.sample.demo:mipmap/icon) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:7:2-31:16: AAPT: error: resource style/AppThemeOverride (aka com.sample.demo:style/AppThemeOverride) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_banner (aka com.sample.demo:drawable/app_banner) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_icon (aka com.sample.demo:drawable/app_icon) not found.

This is right direction and we need anything else. Any ideas?

soywiz commented 2 weeks ago

As I see you've already created the issue from the discusstion, thanks for that :)

For this problem. Could you try to comment or remove these lines: https://github.com/AShynkevich/korge-test/blob/master/gradle.properties#L6-L7 Also try to set https://github.com/AShynkevich/korge-test/blob/master/gradle/libs.versions.toml#L2 to korge = { id = "com.soywiz.korge", version = "6.0.0-beta2" }

I did it (push it) and have another error after build:

./gradlew clean build

* What went wrong:
Execution failed for task ':processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:7:2-31:16: AAPT: error: resource mipmap/icon (aka com.sample.demo:mipmap/icon) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:7:2-31:16: AAPT: error: resource style/AppThemeOverride (aka com.sample.demo:style/AppThemeOverride) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_banner (aka com.sample.demo:drawable/app_banner) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_icon (aka com.sample.demo:drawable/app_icon) not found.

This is right direction and we need anything else. Any ideas?

Can you try (instead of build), ./gradlew runJvmAutoreload?

AShynkevich commented 2 weeks ago

As I see you've already created the issue from the discusstion, thanks for that :)

For this problem. Could you try to comment or remove these lines: https://github.com/AShynkevich/korge-test/blob/master/gradle.properties#L6-L7 Also try to set https://github.com/AShynkevich/korge-test/blob/master/gradle/libs.versions.toml#L2 to korge = { id = "com.soywiz.korge", version = "6.0.0-beta2" }

I did it (push it) and have another error after build: ./gradlew clean build

* What went wrong:
Execution failed for task ':processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:7:2-31:16: AAPT: error: resource mipmap/icon (aka com.sample.demo:mipmap/icon) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:7:2-31:16: AAPT: error: resource style/AppThemeOverride (aka com.sample.demo:style/AppThemeOverride) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_banner (aka com.sample.demo:drawable/app_banner) not found.

     ERROR: /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml:17:3-30:14: AAPT: error: resource drawable/app_icon (aka com.sample.demo:drawable/app_icon) not found.

This is right direction and we need anything else. Any ideas?

Can you try (instead of build), ./gradlew runJvmAutoreload?

Done! The command run desktop app: image

What should I do If I need to build jar/apk bundle or run android version?

PS: I tried to run ./gradlew compileReleaseKotlinAndroid but had the error above

soywiz commented 2 weeks ago

Can you put here the generated /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml file?

AShynkevich commented 2 weeks ago

Can you put here the generated /Users/user_name/KorgeProjects/test-korge/build/AndroidManifest.xml file?

Sure

AndroidManifest.xml.zip

AShynkevich commented 2 weeks ago

@soywiz, is anything else needed from my side?

soywiz commented 2 weeks ago

Does this tasks work for you?

./gradlew runAndroidDebug
./gradlew runAndroidEmulatorDebug
./gradlew runAndroidDeviceDebug

Also if you call ./gradlew compileReleaseKotlinAndroid twice, the error reproduces?

I belive it compileReleaseKotlinAndroid have some files generated after when required, while run* variants works as expected. build was not tested directly, because it was so slow on e2e tests (including all kotlin native targets) that it is not supported directly. Only tasks for specific targets are supported.

Tasks in the groups install, run and package are supported (and at least jvmTest in the verification group). The other are intermediates that might not be tested.

soywiz commented 2 weeks ago

For android these are the tasks:

https://docs.korge.org/targets/android/

AShynkevich commented 2 weeks ago

Does this tasks work for you?

./gradlew runAndroidDebug
./gradlew runAndroidEmulatorDebug
./gradlew runAndroidDeviceDebug

Yes, it works for me - thanks! Also I tried the command:

./gradlew installAndroidRelease

It built successfully, but there are many warnings which I can't fix in the project:

Please remove 'concurrentMain' and include its sources to one of the default source set: https://kotl.in/hierarchy-template
For example:

    kotlin.sourceSets.commonMain.kotlin.srcDir() // <-- pass here sources directory

Or add explicit dependency if the solution above is not applicable:

    kotlin.sourceSets["concurrentMain"].dependsOn(commonMain)

See https://kotl.in/connecting-source-sets for more details.

w: Kotlin Source Set 'concurrentTest' is included in compilations of Kotlin Targets: 'jvm', 'iosArm64', 'iosSimulatorArm64'  
but it doesn't depend on 'commonTest'

Please remove 'concurrentTest' and include its sources to one of the default source set: https://kotl.in/hierarchy-template
For example:

    kotlin.sourceSets.commonMain.kotlin.srcDir() // <-- pass here sources directory

Or add explicit dependency if the solution above is not applicable:

    kotlin.sourceSets["concurrentTest"].dependsOn(commonTest)

See https://kotl.in/connecting-source-sets for more details.

> Task :deps:processReleaseManifest
/Users/user_name/KorgeProjects/test-korge/deps/build/AndroidManifest.xml:3:5-74 Warning:
        uses-sdk:minSdkVersion value (18) specified in the manifest file is ignored. It is overridden by the value declared in the DSL or the variant API, or 1 if not declared/present. Current value is (1).
/Users/user_name/KorgeProjects/test-korge/deps/build/AndroidManifest.xml:3:5-74 Warning:
        uses-sdk:targetSdkVersion value (30) specified in the manifest file is ignored. It is overridden by the value declared in the DSL or the variant API, or 1 if not declared/present. Current value is (1).

Looks like the fix is possible inside the gradle plugin

Also if you call ./gradlew compileReleaseKotlinAndroid twice, the error reproduces?

I belive it compileReleaseKotlinAndroid have some files generated after when required, while run* variants works as >expected. build was not tested directly, because it was so slow on e2e tests (including all kotlin native targets) that it is > not supported directly. Only tasks for specific targets are supported.

Unfortunately, reproduces :(

soywiz commented 2 weeks ago

Glad to know that the first commands work for you.

I have done some fixes and improvements in the main branch. For now, use the tasks from the documentation.

AShynkevich commented 2 weeks ago

Sounds awesome! thank you so much ^_^