Hi, all. When I try to build my project (it's very...
# compose
d
Hi, all. When I try to build my project (it's very early in development, not quite ready for an MVP) I get errors like this (pulled from the overall stack trace):
Copy code
* What went wrong:
A problem occurred configuring root project 'variant'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:8.5.0.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:8.5.0
         project : > com.android.library:com.android.library.gradle.plugin:8.5.0
But the project can build and run well from Android Studio. What can I do to fix the build so that things like SonarQube can publish realistic code status? My project's repo is here if anybody would like to look at things: https://github.com/comixed/variant/
m
Hey there, what exactly do you mean by
When I try to build my project (it's very early in development, not quite ready for an MVP) I get errors like this (pulled from the overall stack trace)
? Do you mean by command line, in a build step? What build command did you use? Have you used the gradle task list in the side bar? I had no issues with building your project. Tried the .
/gradlew build
command and some builds from the command line. aside from some warnings, there was no issue with any outputs. Other things to check: • ./gradlew build --info to get better output • java -version check if this statements nets the same result as in the sdk dropdown
d
I'm trying to build from the command line: ./gradlew clean build check sonar --info
I just did: ./gradlew build --info and I see the same output:
Copy code
darryl_pierce@M-L02PXVK49Y [12:29:45] [~/Repositories/comixed/variant] [main]
-> % ./gradlew build --info
Initialized native services in: /Users/darryl_pierce/.gradle/native
Initialized jansi services in: /Users/darryl_pierce/.gradle/native
Received JVM installation metadata from '/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home': {JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home/jre, JAVA_VERSION=1.8.0_411, JAVA_VENDOR=Oracle Corporation, RUNTIME_NAME=Java(TM) SE Runtime Environment, RUNTIME_VERSION=1.8.0_411-b09, VM_NAME=Java HotSpot(TM) 64-Bit Server VM, VM_VERSION=25.411-b09, VM_VENDOR=Oracle Corporation, OS_ARCH=aarch64}
Found daemon DaemonInfo{pid=24162, address=[d6632f2f-d5f1-464f-9cea-9fb532387296 port:55127, addresses:[/127.0.0.1]], state=Idle, lastBusy=1742825996542, context=DefaultDaemonContext[uid=4f5b7fd0-0d96-4d79-90a9-aa27c39b5bc3,javaHome=/Users/darryl_pierce/Applications/Android Studio.app/Contents/jbr/Contents/Home,daemonRegistryDir=/Users/darryl_pierce/.gradle/daemon,pid=24162,idleTimeout=10800000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048M,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} however its context does not match the desired criteria.
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home,daemonRegistryDir=/Users/darryl_pierce/.gradle/daemon,pid=34750,idleTimeout=null,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=-Xmx2048M,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=4f5b7fd0-0d96-4d79-90a9-aa27c39b5bc3,javaHome=/Users/darryl_pierce/Applications/Android Studio.app/Contents/jbr/Contents/Home,daemonRegistryDir=/Users/darryl_pierce/.gradle/daemon,pid=24162,idleTimeout=10800000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048M,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]

  Looking for a different daemon...
The client will now receive all logging from the daemon (pid: 30193). The daemon log file: /Users/darryl_pierce/.gradle/daemon/8.7/daemon-30193.out.log
Starting 9th build in daemon [uptime: 2 hrs 50 mins 17.339 secs, performance: 100%, GC rate: 1.00/s, heap usage: 2% of 1.3 GiB]
Using 12 worker leases.
Calculating task graph as no cached configuration is available for tasks: build
Now considering [/Users/darryl_pierce/Repositories/comixed/variant] as hierarchies to watch
Watching the file system is configured to be enabled if available
Now considering [/Users/darryl_pierce/Repositories/comixed/variant] as hierarchies to watch
File system watching is active
Starting Build
Settings evaluated using settings file '/Users/darryl_pierce/Repositories/comixed/variant/settings.gradle.kts'.
Using local directory build cache for the root build (location = /Users/darryl_pierce/.gradle/caches/build-cache-1, removeUnusedEntriesAfter = 7 days).
Type-safe project accessors is an incubating feature.
Projects loaded. Root project using build file '/Users/darryl_pierce/Repositories/comixed/variant/build.gradle.kts'.
Included projects: [root project 'variant', project ':androidVariant', project ':shared']

> Configure project :
Evaluating root project 'variant' using build file '/Users/darryl_pierce/Repositories/comixed/variant/build.gradle.kts'.

0 problems were found storing the configuration cache.

See the complete report at file:///Users/darryl_pierce/Repositories/comixed/variant/build/reports/configuration-cache/22n2vbcub9kx0vjebpmcz1tqc/e1zrlrw0ev1fo55u1xbz8cbsa/configuration-cache-report.html

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'variant'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:8.5.0.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:8.5.0
         project : > com.android.library:com.android.library.gradle.plugin:8.5.0
      > No matching variant of com.android.tools.build:gradle:8.5.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but:
          - Variant 'apiElements' declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'javadocElements' declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'sourcesElements' declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
   > Could not resolve app.cash.sqldelight:gradle-plugin:2.0.2.
     Required by:
         project : > app.cash.sqldelight:app.cash.sqldelight.gradle.plugin:2.0.2
      > No matching variant of app.cash.sqldelight:gradle-plugin:2.0.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but:
          - Variant 'apiElements' declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
   > Could not resolve org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373.
     Required by:
         project : > org.sonarqube:org.sonarqube.gradle.plugin:4.4.1.3373
      > No matching variant of org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but:
          - Variant 'apiElements' declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'javadocElements' declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'sourcesElements' declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')

* Try:
> Review the variant matching algorithm at <https://docs.gradle.org/8.7/userguide/variant_attributes.html#sec:abm_algorithm>.
> No matching variant errors are explained in more detail at <https://docs.gradle.org/8.7/userguide/variant_model.html#sub:variant-no-match>.
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.

BUILD FAILED in 529ms
Watched directory hierarchies: [/Users/darryl_pierce/Repositories/comixed/variant]
Configuration cache entry stored.
m
The logs indicate you're using java 8 on the commandline 1.
com.android.tools.build:gradle:8.5.0
requires Java 11 2.
app.cash.sqldelight:gradle-plugin:2.0.2
requires Java 17 3.
org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373
requires Java 11
🙌 1
d
Interesting: the box I'm using has JDK8, 11, 17, and 21 on it, but defaults to 8. When I switched to 11 it didn't fail when I ran "./gradlew build --info"
How does that affect that the project uses:
Copy code
jvmTarget = "1.8"
in the gradle build files?
m
1. This only specifies the byte code version that the Kotlin compiler should generate when compiling your Kotlin code. This is about the output of the compilation process, not the Java version running the build itself. The effects are that the bytecode is compatible with Java 8 JVMs. So it should not affect much all in a KMP-Project targeting iOS and android. The only thing is that you won't be able to use Java language features from versions higher than 8 in your generated bytecode.
👍 1