Cannot build first project in Android Studio

Hello,

I followed the installation instructions for MicroEJ with Android Studio and tried to build the basic template project. However, I am receiving the following error when building:

Unable to find method ‘‘org.gradle.api.artifacts.dsl.DependencyAdder org.gradle.api.plugins.jvm.JvmComponentDependencies.getRuntimeOnly()’’
‘org.gradle.api.artifacts.dsl.DependencyAdder org.gradle.api.plugins.jvm.JvmComponentDependencies.getRuntimeOnly()’

Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

I have already tried the suggested actions to no avail. Any ideas on how to fix this?

Hello @seng,

It seems to be related to an API break from Gradle (similar issue)
We have updated to new API in the version 0.16.0 of our plugins (see CHANGELOG).

Also, I do not reproduce with Android Studio Iguana (2023.2.1 Patch 2) & Plugin “MicroEJ for Android Studio” 0.4.0.

Alternatively, you can force the Gradle version to the one configured by the generated project by using the Gradle wrapper.

Best regards,
Rémy

Hi @rlouedec,

Thanks for the prompt response. I seem to have worked around it by commenting out the “testing” section for the time being. For reference, here’s my setup (using Gradle 8.6 atm):

Android Studio Jellyfish | 2023.3.1 Patch 1
Build #AI-233.14808.21.2331.11842104, built on May 15, 2024
Runtime version: 17.0.10+0–11572160 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4012M
Cores: 12
Registry:
ide.experimental.ui=true
Non-Bundled Plugins:
com.microej.tools.android-studio-plugin (0.4.0)

However, now I’m facing another issue: I cannot resolve the main dependencies for the UI from this tutorial: Create Your First Embedded App with MicroEJ Using Android Studio (youtube.com).

Am I missing something else in my setup? I have added both microej.init.gradle.kts and microej.wear.init.gradle.kts to my .gradle/init.d.

@seng,

Then, I would recommend to update MicroEJ plugin in build.gradle.kts to latest version (0.17.0).
(see screenshot in my previous answer)

I do not reproduce with:

You can check the resolve attempts in the logs:

If you do not have those repositories, can you please check your settings.gradle.kts & build.gradle.kts ? The configuration may be overridden.

If you have the same list, it is a network issue.
If you are behind an HTTP proxy, see Networking with Gradle.
If your network redirects to proxy transparently (with solutions like ZScaler), you need to add the proxy server certificate to the trustore of the Gradle JDK (In Android Studio: Settings > Build, Execution, Deployment > Build Tools > Gradle).

Best regards,
Rémy

@rlouedec thanks again. I can confirm that the MicroEJ plugin is already at 0.17.0 in build.gradle.kts.

Hmm, it’s not showing me where gradle searched in the output, just that it couldn’t find them. See my first screenshot above. Interestingly, it seems to resolve ej.api:microui but not ej.library.ui:mwt or ej.library.ui:widget which leads me to believe it’s not a networking issue.

For reference, here’s all the deps which seem to be resolved:
image

build.gradle.kts only contains what’s listed in the tutorial in addition to the stock microEJ project, and settings.gradle.kts is unmodified, so I see no signs of overwriting that config.

Hi @seng,

I am not sure why you do not have the searched locations logs.
Also, the MWT & Widget libraries are available on the same repository than the API modules.

I would need more information to understand what is going wrong on your setup.
Could you run ./gradlew build from the command line to see if you have the searched locations information outside of Android Studio ?
Also, you can run with --info or --debug to get more information.

Best regards,
Rémy