Hi all! I was looking into adding Amper to my new...
# amper
t
Hi all! I was looking into adding Amper to my new project in combination with gradle. I generated a Compose Multiplatform project for Android, iOS and Desktop via https://kmp.jetbrains.com/#newProject though I noticed that the folder structure does not match up with the folder structure used in the documentation of Amper. The most obvious being that in the generated project there now is a
composeApp
directory which contains
androidMain
,
iosMain
,
desktopMain
and
commonMain
with a single
build.gradle.kts
file in the
composeApp
directory. How would one go about adding Amper into this? Is it just: add a
module.yml
in each platform specific directory and in commonMain, or must there also be one in
composeApp
as a replacement for the
build.gradle.kts
?
a
That's correct, there is no such thing as compose app in Amper by design. Instead each application has a separate module and
module.yaml
. Here is an example. Also the template gallery has templates with Amper projects that you can use
t
Okay so just to confirm: It isn't possible to use the
composeApp
structure (by design). I should switch to the more traditional structure of having a module for each platform and shared? Will there in the future be a possibility to use it with the
composeApp
structure?
a
That's correct. Right now we tend to think that having separate platform modules results in a more straightforward configuration. specifically because different platforms have so different packaging/distribution pipelines, that putting them in a single configuration file makes things less manageable. So I don't expect an alternative to
composeApp
to appear in Amper, but that's the thing with experiments, we never know for sure where we might end up 🙂
t
That makes sense, I will try to implement it later today. Thanks for you help!
👍 1
@amakeev I just got the example from the Template Gallery which contained iOS and Android. Then I added a folder for
desktopApp
with the
module.yaml
, though when I try to run the
desktopApp
I get:
Copy code
'C:\Users\Tom\Downloads\KMP-App-Template-amper' is not recognized as an internal or external command,
operable program or batch file.
It seems like it is trying to use Amper but instead of doing so it attempts to execute my current working directory as a command?
module.yaml
of
desktopApp
Copy code
product: jvm/app

dependencies:
    - ../shared
    - $compose.desktop.currentOs

settings:
    compose: enabled
I must be missing something but can't figure out what
I also tried by using this exact example that already contains the Desktop app, but I get the same error
Okay so after a bit it just started working, guess it was just Fleet that was delaying. However now the name of my android app module is "android-app" and if I rename it to "androidApp" it still tries to launch the task for the old name?
Copy code
Error: Module 'TestAmper.android-app.main' doesn't exist in project
Could not launch run task
k
Hi Tom! I’ve checked how these predefined run configurations behave on module rename. Some of them don’t survive renaming a module (and in that case you need to “Edit a Copy” and then perform manual modifications), but the
android-app
configuration seem to be recreated after importing the project. Could you please double check it once again? Don’t forget to modify the module name in settings.gradle.kts and reimport the project afterwards. If the configuration does not get renamed, please try to manually “Edit a Copy” of it and modify the module name there. Let me know if that helps.
t
Editing a copy worked, it generated a
run.json
after running it successfully I deleted that json file and it keeps working. This regeneration system behaviour is kinda strange. Is it written out somewhere how it works?
k
The behaviour you are describing sounds like a bug to me. Which version of Fleet are you using? I’ve checked the behaviour in Fleet 1.39.108, and here is what I see after I rename the module folder + its entity in settings.gradle.kts and after I reimport the Gradle project: • The initial android-app configuration still exists and does not work. // this is incorrect: this configuration should have been removed • A new configuration for androidApp has been created, and it works fine. // this is correct
t
I am on the latest version of Fleet (at the time of writing, which was Tuesday). I also renamed the module folder and the entry in
settings.gradle.kts
and re-imported the gradle project. Then after I edit that copy the
run.json
was generated and I altered the
module
in that. Then running the
androidApp
it worked. I then deleted the
run.json
and
androidApp
kept working. Simply renaming the folder
android-app
to
androidApp
did not work (see error message above)
🙏 1