Hi, I'm having some problems building from Xcode. ...
# multiplatform
t
Hi, I'm having some problems building from Xcode. Using the multiplatform app template from Android Studio, I am able to build the iOS app from within Android Studio, but when building from Xcode I get this error
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'My_Application'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:8.2.0-rc02.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:8.2.0-rc02
         project : > com.android.library:com.android.library.gradle.plugin:8.2.0-rc02
      > No matching variant of com.android.tools.build:gradle:8.2.0-rc02 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.2' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:8.2.0-rc02 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.2')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:8.2.0-rc02 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 target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:8.2.0-rc02 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.2')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:8.2.0-rc02 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 target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2')
I didn't change anything in the project before getting this error. What I have tried so far without any luck: • Updating to Kotlin 1.9.20 • Set jvmTarget to 17 • Set Source and target compability to _VERSION_17_ • Declare jvmToolchain(17) • Using Android studio KMM plugin 0.8 • Java home is set en .zshrc (Android Studio version) • Changed Gradle version • Update Android Studio to Hedgehog from Giraffe Now I'm out of ideas 😞
🧵 1
Okay so it seems that Xcode don't care about JAVA_HOME, it uses system Java which was 1.8.. I added the JAVA_HOME as part of the run script and now it works
Copy code
export JAVA_HOME=/Applications/Android\ <http://Studio.app/Contents/jbr/Contents/Home|Studio.app/Contents/jbr/Contents/Home>

cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
a
make sure you are not mixing
zsh
and
sh
tools - they get env variables from different files
214 Views