https://kotlinlang.org logo
Title
d

Dan Peluso

03/23/2021, 6:07 PM
I am not able to get the
compose-jb/templates/multiplatform-jb
to build on my machine. I have the project SDK set to Java 11, but every time I sync my
build.gradle.kts
, the build shows me errors on the (common) and (android) build.gradle.kts. It looks like something is wrong with how I'm importing the SDK, or maybe I have a project structure field wrong. Does this look familiar to anybody else? Cloned the most up-to-date repo and for the life of me I cannot get it to build (with zero code changes) errors in thread
o

olonho

03/23/2021, 6:09 PM
do you have Android SDK installed?
d

Dan Peluso

03/23/2021, 6:13 PM
I do, and my project structure is pointing to that location in the 'Android SDK Location' portion of the Project Structure
o

olonho

03/23/2021, 6:17 PM
what IDEA is that?
d

Dan Peluso

03/23/2021, 6:18 PM
Here are all the build errors I'm getting for just the 'common' build.gradle.kts
this is in Android Studio Canary
o

olonho

03/23/2021, 6:22 PM
use IntelliJ IDEA (CE is fine), MPP support in AS in not yet perfect
d

Dan Peluso

03/23/2021, 8:26 PM
@olonho when moving to Intellij I still get the same build errors. What should I be specifying as my project SDK? I'm using Java 11 and have tried Android 30 but have had no luck
o

olonho

03/23/2021, 8:44 PM
From your error it seems Android SDK is not found
j

jim

03/23/2021, 8:45 PM
I suppose one question is: does building from the command line work?
that will at least allow us to know if this is a issue with your gradle/environment configuration or IDE configuration
d

Dan Peluso

03/23/2021, 9:01 PM
@olonho do you know where I would have to add the android sdk in the project structure? I'm a bit confused because it seems like I need to put JDK 11 as the project SDK but maybe that's my issue. When I try replacing that with Android API 30 it does not fix the build issues
@jim building from the command line does not work, attaching my stacktrace
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/dpeluso/Documents/compose-jb/templates/multiplatform-template/android/build.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> Could not create plugin of type 'AppPlugin'.
> Could not generate a decorated class for type AppPlugin.
> com/android/utils/ILogger
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.android.application']
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:198)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:180)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$applyPlugins$1(DefaultPluginRequestApplicator.java:125)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:125)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:121)
at org.gradle.kotlin.dsl.provider.PluginRequestsHandler.handle(PluginRequestsHandler.kt:48)
at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.applyPluginsTo(KotlinScriptEvaluator.kt:198)
at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.applyPluginsTo(Interpreter.kt:360)
at Program.execute(Unknown Source)
at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.eval(Interpreter.kt:502)
at org.gradle.kotlin.dsl.execution.Interpreter.eval(Interpreter.kt:178)
at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator.evaluate(KotlinScriptEvaluator.kt:120)
at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:51)
at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:36)
at org.gradle.kotlin.dsl.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:34)
at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.configuration.BuildOperationScriptPlugin.lambda$apply$0(BuildOperationScriptPlugin.java:62)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:62)
at org.gradle.configuration.project.BuildScriptProcessor$1.run(BuildScriptProcessor.java:45)
at org.gradle.internal.Factories$1.create(Factories.java:26)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:245)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:226)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:42)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:35)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:102)
at org.gradle.internal.Factories$1.create(Factories.java:26)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:180)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:271)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:265)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:226)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:91)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:63)
at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:710)
at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:145)
at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:36)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:64)
at org.gradle.configuration.DefaultProjectsPreparer.prepareProjects(DefaultProjectsPreparer.java:61)
at org.gradle.configuration.BuildOperatingFiringProjectsPreparer$ConfigureBuild.run(BuildOperatingFiringProjectsPreparer.java:52)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at (cutting to fit slack limit)
* Get more help at <https://help.gradle.org>
BUILD FAILED in 689ms
j

jim

03/23/2021, 9:29 PM
Ok, so it does look like it's clearly an issue locating the Android SDK.
What happens if you type
echo $ANDROID_HOME
d

Dan Peluso

03/23/2021, 9:30 PM
I get nothing
does that work for Mac? I know its how you get path variables on windows but unsure if its the same for Mac
j

jim

03/23/2021, 9:37 PM
Yes,
echo $ANDROID_HOME
should return the path to ANDROID_HOME on Mac and Linux
If you get nothing, then very likely that's the issue
I always get frustrated setting up the Android SDK whenever I reimage my device, and I can never remember how to do it, but I think the steps I use are roughly like https://stackoverflow.com/questions/19986214/setting-android-home-enviromental-variable-on-mac-os-x
Also don't skip the step of adding it to your
~/.bash_profile
or else it will suddenly stop working if you use a different console window or restart your machine or whatever.
d

Dan Peluso

03/23/2021, 10:04 PM
Thanks for helping out! I'm having an issue where although I've added the lines to the ~/.bash_profile whenever I open a new terminal
echo $ANDROID_HOME
does not give me anything. When I run the
source ~/.bash_profile
command tho, I do see the correct path in the echo command. but then it does not persist across terminals (or when restarting the computer). Even after trying to build from the same terminal after running the
source
command the build keeps failing with the same errors
Do you think the build is still failing because I've incorrectly added the bash_profile lines?
j

jim

03/23/2021, 10:08 PM
The lines in your screenshot looks right to me, but it's unclear from your screenshot if there are any other lines in the file, which would surprise me if it's empty. What is the filename you are adding these lines to?
Can you copy-paste the full file path?
d

Dan Peluso

03/23/2021, 10:17 PM
There are no other lines - am I adding to the incorrect bash profile? The path I've been adding to is
File: /Users/dpeluso/.bash_profile
j

jim

03/23/2021, 10:20 PM
I am not sure, as my machines are provisioned by Google's IT department, but my bash profile has always been full of lines. The full path you posted looks very reasonable though.
What happens if you type
echo $SHELL
?
d

Dan Peluso

03/23/2021, 10:23 PM
I get back
/bin/zsh
. As I mentioned this is not one of the three lines in my .bash_profile
j

jim

03/23/2021, 10:23 PM
aah
ok, that explains why your
.bash_profile
was not working; you are not using bash.
🙌 1
Ok, well, this is beyond the scope of what I can advise you on. You will need to decide if you want to switch to bash (I believe you can do this with
chsh -s bin/bash
or if you want to stick with zsh; I don't know about zsh to advise you on configuring it). But ball would be in your court there.
In the mean time, if you do run
source ~/.bash_profile
- does that at least make your command line build start working?
d

Dan Peluso

03/23/2021, 10:31 PM
it does not, I get the same errors sadly
j

jim

03/23/2021, 10:58 PM
😞
Also, what happens if you do
ls -l $ANDROID_SDK_ROOT
d

Dan Peluso

03/24/2021, 12:13 AM
As a side note, I was able to build this without an problems on a different Windows computer
j

jim

03/24/2021, 12:56 AM
oh no, that doesn't look right to me. what do you get if you do
echo $ANDROID_SDK_ROOT
?
Can you try setting
ANDROID_SDK_ROOT
to have the same value as your
ANDROID_HOME
?
let's see if that makes your command line build work better
m

Michal Harakal

03/24/2021, 8:09 AM
@Dan Peluso I am not sure if the error message was the same, but we had have similar troubles if we didn't accepted Android SDK licences once. You can do it by Android SDK Manager via AS/IntelliJ File->Tools->Android-Sdk Manager or via command line on MacOS
$ANDROID_HOME/tools/bin/sdkmanager --licenses
h

hfhbd

03/25/2021, 7:52 AM
on zsh the "environment config" file is called
.zshenv
in`~`