Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Hello world Kotlin Jetpack Compose Example; Fixes:#3550 #3696

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

himanshumahajan138
Copy link
Contributor

Pull Request:

[Request for Help] Unresolved Reference Errors in Android Project with Jetpack Compose

Issue:#3550


Description:

I am facing unresolved reference errors when compiling my Android project using Kotlin and Jetpack Compose. Below is a summary of the issue and what I have tried so far. I need assistance to resolve this.

My perspective is that it is unable to connect with the kotlin compiler and also there is no support for the BOM for jetpack compose just like present in the gradle and this leads to dependency conflicts also


Error Messages:


File : MainActivity.kt

error: unresolved reference: activity
import androidx.activity.ComponentActivity
                    ^
error: unresolved reference: activity
import androidx.activity.compose.setContent
                    ^
error: unresolved reference: compose
import androidx.compose.material3.Text
                    ^
error: unresolved reference: compose
import androidx.compose.runtime.Composable
                    ^
error: unresolved reference: ComponentActivity
class MainActivity : ComponentActivity() {
                     ^
error: unresolved reference: onCreate
super.onCreate(savedInstanceState)
           ^
error: unresolved reference: setContent
setContent {
           ^
error: unresolved reference: Composable
@Composable
           ^
error: unresolved reference: Text
Text(text = name)
           ^
app.compile Kotlin compiler failed with exit code 1 (COMPILATION_ERROR)

Steps I Have Taken:

  1. Verified that the correct dependencies for Jetpack Compose and Android activity are included in build.mill.
  2. Cleaned the project and rebuilt using the Mill build system.
  3. Double-checked the Kotlin version compatibility with Jetpack Compose.

Request:

I need help in identifying why the references for activity and compose are unresolved, despite including the relevant dependencies in build.mill. Any guidance or fixes would be greatly appreciated.


Sir @lihaoyi please review the code and guide me...

@lihaoyi
Copy link
Member

lihaoyi commented Oct 10, 2024

@himanshumahajan138 maybe try again on latest master see if it's fixed by the recent klib changes?

@0xnm
Copy link
Contributor

0xnm commented Oct 10, 2024

Android artifacts are distributed as .aar files and the following change in Coursier coursier/coursier#3093 only added support of .klib files, but not .aar, that is why you cannot find any Android-specific dependency in the classpath. Coursier should add .aar support first.

@lihaoyi
Copy link
Member

lihaoyi commented Oct 10, 2024

Thanks @0xnm ! @alexarchambault any chance we could add aar to the coursier download list? is that something we can just do ourselves in Mill once #3703 lands?

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 10, 2024

Android artifacts are distributed as .aar files and the following change in Coursier coursier/coursier#3093 only added support of .klib files, but not .aar, that is why you cannot find any Android-specific dependency in the classpath. Coursier should add .aar support first.

@0xnm Hats off to you and your Experience sir!

WOW ! i was trying to solve why this was not working checked alot of files and out folders but i think this needs a pause till we get .aar support for android specific dependency

@lihaoyi what u say sir...

@alexarchambault
Copy link
Contributor

alexarchambault commented Oct 10, 2024

@lihaoyi #3703 should help you pull those files on your own, yes. Plus it doesn't break bin compat now, so it could be merged. Once it lands, something like this should pull aar files:

def artifactTypes = super.artifactTypes() + coursier.Type("aar")

@alexarchambault
Copy link
Contributor

Adding them by default in coursier could be an option too… 🤔

@himanshumahajan138
Copy link
Contributor Author

Is there any manual process for now to add the support for android specific dependencies specifically jetpack compose

@alexarchambault
Copy link
Contributor

alexarchambault commented Oct 10, 2024

@himanshumahajan138 Cherry-picking the commits of #3703 and adding the snippet of #3696 (comment) to your android modules ought to work

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 10, 2024

actually what i think could be better is first let your #3703 merged to master and then do the further changes to this code to resolve conflicts

@lihaoyi
Copy link
Member

lihaoyi commented Oct 10, 2024

@alexarchambault sounds good! I'm happy as long as we have some way to configure it in Mill, whether it should go upstream into Coursier is up to you

@lihaoyi
Copy link
Member

lihaoyi commented Oct 10, 2024

@himanshumahajan138 I've merged the other PR, you can try using it

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 10, 2024

Please Check Latest Commit...
Error is Still not resolved even after adding coursier.Type("aar") i think this need some serious attention!

[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:4:17: error: unresolved reference: activity
[3443]   import androidx.activity.ComponentActivity
[3443]                   ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:5:17: error: unresolved reference: activity
[3443]   import androidx.activity.compose.setContent
[3443]                   ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:6:17: error: unresolved reference: compose
[3443]   import androidx.compose.material3.Text
[3443]                   ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:7:17: error: unresolved reference: compose
[3443]   import androidx.compose.runtime.Composable
[3443]                   ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:9:22: error: unresolved reference: ComponentActivity
[3443]   class MainActivity : ComponentActivity() {
[3443]                        ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:10:5: error: 'onCreate' overrides nothing
[3443]       override fun onCreate(savedInstanceState: Bundle?) {
[3443]       ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:11:15: error: unresolved reference: onCreate
[3443]           super.onCreate(savedInstanceState)
[3443]                 ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:12:9: error: unresolved reference: setContent
[3443]           setContent {
[3443]           ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:18:2: error: unresolved reference: Composable
[3443]   @Composable
[3443]    ^
[3443]   /home/runner/work/mill/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-2/app/src/main/kotlin/com/helloworld/app/MainActivity.kt:20:5: error: unresolved reference: Text
[3443]       Text(text = name)
[3443]       ^
[3443]   1 tasks failed
[3443]   show 1 tasks failed
[3443]   app.compile Kotlin compiler failed with exit code 1 (COMPILATION_ERROR)
[3443]   ,)

i think we need to have a particular case for androidx which allowsjetpack compose support for the Kotlin Android application
Also, one thing to consider is adding BOM support this will allow us to use latest compatible androidx dependencies without conflicts

please pardon me if i did something in wrong way but i think its following the solution suggested in this conversation

@himanshumahajan138
Copy link
Contributor Author

See this example for the build.gradle how easily a non jetpack compose project can be converted to jetpack compose by doing changes in the build file, the usage of compose=true and BOM version provides best compatible versions for all of the dependencies it would be great if we can also achieve this type of simplicity and scalability

android {
    //...
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        //...
        //enable the compose functionality
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.3.2'
    }
}

dependencies {
    //...
    // Compose
    def composeBom = platform('androidx.compose:compose-bom:2024.09.03')
    implementation(composeBom)
    androidTestImplementation(composeBom)

    implementation "androidx.compose.runtime:runtime"
    implementation "androidx.compose.ui:ui"
    implementation "androidx.compose.foundation:foundation"
    implementation "androidx.compose.foundation:foundation-layout"
    implementation "androidx.compose.material:material"
    implementation "androidx.compose.runtime:runtime-livedata"
    implementation "androidx.compose.ui:ui-tooling"
    implementation "com.google.accompanist:accompanist-themeadapter-material:0.28.0"
    //...
}

Please share thoughts on this implementation if possible...

@alexarchambault
Copy link
Contributor

@himanshumahajan138 The following patch brings the *.aar files in the compilation class path:

diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala
index f72bc67c74..4d92101bcb 100644
--- a/scalalib/src/mill/scalalib/JavaModule.scala
+++ b/scalalib/src/mill/scalalib/JavaModule.scala
@@ -545,7 +545,10 @@ trait JavaModule
    * Resolved dependencies based on [[transitiveIvyDeps]] and [[transitiveCompileIvyDeps]].
    */
   def resolvedIvyDeps: T[Agg[PathRef]] = Task {
-    defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps())
+    defaultResolver().resolveDeps(
+      transitiveCompileIvyDeps() ++ transitiveIvyDeps(),
+      artifactTypes = Some(artifactTypes())
+    )
   }

   /**

(not sure why, I had to remove example/kotlinlib/android/2-jetpack-compose-hello-world/out for that to work)

Then it seems some missing classes are in classes.jar files inside some *.aar. Not sure how these should be taken into account.

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 11, 2024

After a very Deep study about pom, aar, jar files i found that the actual cause for this error is that the versions of dependencies i am using does not provide jar support instead they provide pom and some aar support and if we think we can upgrade the versions of dependencies then we can't even do that also why ?

  • because if we want to upgrade the versions then there are only two options:
    • either we use BOM for adding only jetpack support
    • or we have to update versions of every dependency which we have ever used in mill related to maven or kotlin dependencies

Now what could be the solution then my approach:

  • we can add support for both pom and aar files and not only support we have to handle those files to make them workable just like gradle do
  • then we have to add support for BOM for resolving compatibility issues

in short: we need support for pom, aar files

@lihaoyi @alexarchambault @0xnm please check out if we can achieve this thing

@nxm
Copy link

nxm commented Oct 11, 2024

lgtm

@himanshumahajan138
Copy link
Contributor Author

for a proof i want to share the compileClasspath.json see we have some the androidx jar files but we don't for activity, compose, material3 and more
but the shocking thing is that these dependencies are downloaded in the .cache folder but have pom and aar files instead of jar and they are not recognized by the mill classpath parser

{
    "value": [
        "qref:v1:3f5e39d7:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.jar",
        "qref:v1:9d59d37e:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compiler/compiler/1.5.14/compiler-1.5.14.jar",
        "qref:v1:5816c69f:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compose-compiler/0.1.0-dev17/compose-compiler-0.1.0-dev17.jar",
        "qref:v1:3108dab7:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar",
        "qref:v1:6217c708:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/annotation/annotation/1.5.0/annotation-1.5.0.jar",
        "qref:v1:e565bb36:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/collection/collection/1.0.0/collection-1.0.0.jar",
        "qref:v1:cf0fcfef:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-common-java8/2.3.0/lifecycle-common-java8-2.3.0.jar",
        "qref:v1:88f3054d:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.7.10/kotlin-stdlib-common-1.7.10.jar",
        "qref:v1:935e66b0:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-android/1.6.4/kotlinx-coroutines-android-1.6.4.jar",
        "qref:v1:9a10a4e2:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.6.4/kotlinx-coroutines-core-1.6.4.jar",
        "qref:v1:af06551d:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.6/kotlinx-coroutines-core-common-1.3.6.jar",
        "qref:v1:69b55492:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-collections-immutable-jvm/0.3/kotlinx-collections-immutable-jvm-0.3.jar",
        "qref:v1:a5db885a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/concurrent/concurrent-futures/1.1.0/concurrent-futures-1.1.0.jar",
        "qref:v1:ed281d85:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/arch/core/core-common/2.2.0/core-common-2.2.0.jar",
        "qref:v1:b93dc0ea:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-common/2.6.1/lifecycle-common-2.6.1.jar",
        "qref:v1:73c3ef17:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/1.0/listenablefuture-1.0.jar",
        "qref:v1:f73202bc:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.6.4/kotlinx-coroutines-core-jvm-1.6.4.jar",
        "qref:v1:21c7f106:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.21/kotlin-stdlib-jdk8-1.6.21.jar",
        "qref:v1:d26d4353:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.21/kotlin-stdlib-jdk7-1.6.21.jar",
        "ref:v0:c984eca8:/home/mrblacked/opensource/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-1/app/compile-resources",
        "ref:v0:87580889:/home/mrblacked/opensource/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-1/out/androidSdkModule0/installAndroidSdk.dest/platforms/android-35/android.jar"
    ],
    "valueHash": -704347053,
    "inputsHash": 997467805
}

@himanshumahajan138
Copy link
Contributor Author

lgtm

sorry, i mistakenly mentioned your profile

@0xnm
Copy link
Contributor

0xnm commented Oct 11, 2024

we can add support for both pom and aar files

pom files are already supported. It is essential piece of the artifact description for the Maven-based publication, you can check that these files exist in all the locations of artifacts you've pulled (for example, you can check /home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.7.10/ from the log you've posted)

then we have to add support for BOM for resolving compatibility issues

Strictly speaking it is not needed to make things work. It is just a handy descriptor of the versions of the artifacts that will be used, but nothing prevents to specify versions individually, without BOM.

I believe you need to wait for the #3719 to be merged, because you are interested in compile classpath, not in the runtime one.

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 11, 2024

Strictly speaking it is not needed to make things work. It is just a handy descriptor of the versions of the artifacts that will be used, but nothing prevents to specify versions individually, without BOM.

yaa i do agree, for sake of simplicity adding BOM will remove the individual versions addition, it will automatically fetch the latest compatible dependencies versions for jetpack compose

lihaoyi pushed a commit that referenced this pull request Oct 11, 2024
Follow-up of #3703 that added
`JavaModule.artifactTypes`. `JavaModule` performs two dependency
resolutions: one for `compileClasspath`, the other for `runClasspath`.
#3703 used `artifactTypes` in
the `runClasspath` one, but not in the `compileClasspath` one. The PR
here fixes that, and adds unit tests for both paths.

This addresses the issues found around
#3696 (comment).
@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 11, 2024

Got the aar files in the compileClasspath.json but Error (unresolved reference) still not resolved 😅

why its happening i have checked that we have proper classpath but still why this is happening

{
    "value": [
        "qref:v1:3f5e39d7:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.jar",
        "qref:v1:e37d459e:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity/1.8.2/activity-1.8.2.aar",
        "qref:v1:7cfcc4d0:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity-compose/1.8.2/activity-compose-1.8.2.aar",
        "qref:v1:bfcc6e76:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity-ktx/1.8.2/activity-ktx-1.8.2.aar",
        "qref:v1:8a2ffc1d:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui/1.3.3/ui-1.3.3.aar",
        "qref:v1:af578c31:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material3/material3/1.0.1/material3-1.0.1.aar",
        "qref:v1:a2bbcff3:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/runtime/runtime/1.3.3/runtime-1.3.3.aar",
        "qref:v1:9d59d37e:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compiler/compiler/1.5.14/compiler-1.5.14.jar",
        "qref:v1:983cd848:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compose-runtime/0.1.0-dev14/compose-runtime-0.1.0-dev14.aar",
        "qref:v1:5816c69f:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compose-compiler/0.1.0-dev17/compose-compiler-0.1.0-dev17.jar",
        "qref:v1:3108dab7:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar",
        "qref:v1:6217c708:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/annotation/annotation/1.5.0/annotation-1.5.0.jar",
        "qref:v1:e565bb36:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/collection/collection/1.0.0/collection-1.0.0.jar",
        "qref:v1:75bac173:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/core/core/1.9.0/core-1.9.0.aar",
        "qref:v1:a34c06da:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-runtime/2.6.1/lifecycle-runtime-2.6.1.aar",
        "qref:v1:80924c80:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-viewmodel/2.6.1/lifecycle-viewmodel-2.6.1.aar",
        "qref:v1:15db51a4:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-viewmodel-savedstate/2.6.1/lifecycle-viewmodel-savedstate-2.6.1.aar",
        "qref:v1:489fcd47:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/profileinstaller/profileinstaller/1.3.0/profileinstaller-1.3.0.aar",
        "qref:v1:fa235f85:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/savedstate/savedstate/1.2.1/savedstate-1.2.1.aar",
        "qref:v1:bd75ee84:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/tracing/tracing/1.0.0/tracing-1.0.0.aar",
        "qref:v1:522c02a5:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/runtime/runtime-saveable/1.3.3/runtime-saveable-1.3.3.aar",
        "qref:v1:e7055f51:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/core/core-ktx/1.9.0/core-ktx-1.9.0.aar",
        "qref:v1:693c5e76:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-runtime-ktx/2.6.1/lifecycle-runtime-ktx-2.6.1.aar",
        "qref:v1:fc5dfa9b:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-viewmodel-ktx/2.6.1/lifecycle-viewmodel-ktx-2.6.1.aar",
        "qref:v1:30654111:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/savedstate/savedstate-ktx/1.2.1/savedstate-ktx-1.2.1.aar",
        "qref:v1:ef4aebfd:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar",
        "qref:v1:8c728d3f:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-geometry/1.3.3/ui-geometry-1.3.3.aar",
        "qref:v1:4180e860:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-graphics/1.3.3/ui-graphics-1.3.3.aar",
        "qref:v1:474b6177:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-text/1.3.3/ui-text-1.3.3.aar",
        "qref:v1:30dfe073:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-unit/1.3.3/ui-unit-1.3.3.aar",
        "qref:v1:7c7a3be5:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-util/1.3.3/ui-util-1.3.3.aar",
        "qref:v1:73145504:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/customview/customview-poolingcontainer/1.0.0/customview-poolingcontainer-1.0.0.aar",
        "qref:v1:cf0fcfef:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-common-java8/2.3.0/lifecycle-common-java8-2.3.0.jar",
        "qref:v1:88f3054d:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.7.10/kotlin-stdlib-common-1.7.10.jar",
        "qref:v1:935e66b0:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-android/1.6.4/kotlinx-coroutines-android-1.6.4.jar",
        "qref:v1:9a10a4e2:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.6.4/kotlinx-coroutines-core-1.6.4.jar",
        "qref:v1:f2933d53:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/animation/animation-core/1.1.1/animation-core-1.1.1.aar",
        "qref:v1:576bac13:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/foundation/foundation/1.2.0/foundation-1.2.0.aar",
        "qref:v1:38f84fce:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/foundation/foundation-layout/1.2.0/foundation-layout-1.2.0.aar",
        "qref:v1:8aca21bb:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material/material-icons-core/1.0.2/material-icons-core-1.0.2.aar",
        "qref:v1:35ba134d:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material/material-ripple/1.0.0/material-ripple-1.0.0.aar",
        "qref:v1:af06551d:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.6/kotlinx-coroutines-core-common-1.3.6.jar",
        "qref:v1:69b55492:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-collections-immutable-jvm/0.3/kotlinx-collections-immutable-jvm-0.3.jar",
        "qref:v1:efb76e7d:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/annotation/annotation-experimental/1.3.0/annotation-experimental-1.3.0.aar",
        "qref:v1:a5db885a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/concurrent/concurrent-futures/1.1.0/concurrent-futures-1.1.0.jar",
        "qref:v1:3eb5bb78:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/versionedparcelable/versionedparcelable/1.1.1/versionedparcelable-1.1.1.aar",
        "qref:v1:ed281d85:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/arch/core/core-common/2.2.0/core-common-2.2.0.jar",
        "qref:v1:706df7e2:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/arch/core/core-runtime/2.2.0/core-runtime-2.2.0.aar",
        "qref:v1:b93dc0ea:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-common/2.6.1/lifecycle-common-2.6.1.jar",
        "qref:v1:40a9b681:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-livedata-core/2.6.1/lifecycle-livedata-core-2.6.1.aar",
        "qref:v1:3298f778:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/startup/startup-runtime/1.1.1/startup-runtime-1.1.1.aar",
        "qref:v1:73c3ef17:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/1.0/listenablefuture-1.0.jar",
        "qref:v1:f73202bc:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.6.4/kotlinx-coroutines-core-jvm-1.6.4.jar",
        "qref:v1:21c7f106:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.21/kotlin-stdlib-jdk8-1.6.21.jar",
        "qref:v1:dd3ec4a3:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/animation/animation/1.1.1/animation-1.1.1.aar",
        "qref:v1:d26d4353:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.21/kotlin-stdlib-jdk7-1.6.21.jar",
        "ref:v0:c984eca8:/home/mrblacked/opensource/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-1/app/compile-resources",
        "ref:v0:87580889:/home/mrblacked/opensource/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-1/out/androidSdkModule0/installAndroidSdk.dest/platforms/android-35/android.jar"
    ],
    "valueHash": -326117419,
    "inputsHash": 1540984616
}

ERROR: #3696 (comment)

@0xnm
Copy link
Contributor

0xnm commented Oct 11, 2024

aar file format is not the same as jar - it includes Android-specific metadata (manifest, for example), resources + classic jar package with JVM bytecode inside (class files).

Now, since you have it on the disk, you need to process it first to be able to feed included jar to the compiler, resources to aapt, etc.

Also please convert this PR to Draft until you have completely working solution to avoid notifications been sent for every action made here.

@himanshumahajan138 himanshumahajan138 marked this pull request as draft October 11, 2024 14:34
@himanshumahajan138
Copy link
Contributor Author

Also please convert this PR to Draft until you have completely working solution to avoid notifications been sent for every action made here.

yaa i forgot sorry for that
and thanks a lot for clarification (your exp is just next level💕)

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 12, 2024

@0xnm Sir Actually i need a little bit more guide about aar files, upon searching i found two ways to use aar files in our project:

  1. Extract the AAR file using standard zip extract

    • Find the classes.jar file in the extracted files
    • Rename it as you like and use that jar file in your project
  2. Rename it to .jar

    • Extract: jar xf filename.jar
    • Repackage: jar cf output.jar input-file(s)

Now i am not sure about the situation like we know that aar contains many files (including manifest, resources, proguard.....) so how can we handle this please explain more about this...

And also, if we are using any of the above method then we should do this step before adding them into the compileclasspath so that we get straight the workable jar files instead of aar

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Oct 12, 2024

After Performing conversion of aar to jar files, its still not working... 😭

Anyone who knows why i am still getting unresolved error even after adding required jar files.

compileClasspath.json

{
    "value": [
        "qref:v1:3f5e39d7:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.jar",
        "qref:v1:046ce457:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity/1.8.2/activity-1.8.2.jar",
        "qref:v1:3359810e:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity-compose/1.8.2/activity-compose-1.8.2.jar",
        "qref:v1:66e0de4f:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity-ktx/1.8.2/activity-ktx-1.8.2.jar",
        "qref:v1:08b42b76:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui/1.3.3/ui-1.3.3.jar",
        "qref:v1:65047cc4:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material3/material3/1.0.1/material3-1.0.1.jar",
        "qref:v1:1fef3355:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/runtime/runtime/1.3.3/runtime-1.3.3.jar",
        "qref:v1:9d59d37e:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compiler/compiler/1.5.14/compiler-1.5.14.jar",
        "qref:v1:95d18e72:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compose-runtime/0.1.0-dev14/compose-runtime-0.1.0-dev14.jar",
        "qref:v1:5816c69f:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compose-compiler/0.1.0-dev17/compose-compiler-0.1.0-dev17.jar",
        "qref:v1:3108dab7:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar",
        "qref:v1:6217c708:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/annotation/annotation/1.5.0/annotation-1.5.0.jar",
        "qref:v1:e565bb36:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/collection/collection/1.0.0/collection-1.0.0.jar",
        "qref:v1:77d74546:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/runtime/runtime-saveable/1.3.3/runtime-saveable-1.3.3.jar",
        "qref:v1:cf0fcfef:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-common-java8/2.3.0/lifecycle-common-java8-2.3.0.jar",
        "qref:v1:88f3054d:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.7.10/kotlin-stdlib-common-1.7.10.jar",
        "qref:v1:935e66b0:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-android/1.6.4/kotlinx-coroutines-android-1.6.4.jar",
        "qref:v1:9a10a4e2:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.6.4/kotlinx-coroutines-core-1.6.4.jar",
        "qref:v1:af06551d:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.6/kotlinx-coroutines-core-common-1.3.6.jar",
        "qref:v1:005ea2ed:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/core/core-ktx/1.9.0/core-ktx-1.9.0.jar",
        "qref:v1:69b55492:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-collections-immutable-jvm/0.3/kotlinx-collections-immutable-jvm-0.3.jar",
        "qref:v1:a5db885a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/concurrent/concurrent-futures/1.1.0/concurrent-futures-1.1.0.jar",
        "qref:v1:ed281d85:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/arch/core/core-common/2.2.0/core-common-2.2.0.jar",
        "qref:v1:b93dc0ea:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-common/2.6.1/lifecycle-common-2.6.1.jar",
        "qref:v1:73c3ef17:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/1.0/listenablefuture-1.0.jar",
        "qref:v1:f73202bc:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.6.4/kotlinx-coroutines-core-jvm-1.6.4.jar",
        "qref:v1:21c7f106:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.21/kotlin-stdlib-jdk8-1.6.21.jar",
        "qref:v1:d26d4353:/home/mrblacked/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.21/kotlin-stdlib-jdk7-1.6.21.jar",
        "ref:v0:87580889:/home/mrblacked/opensource/mill/out/example/kotlinlib/android/2-jetpack-compose-hello-world/local/testCached.dest/sandbox/run-1/out/androidSdkModule0/installAndroidSdk.dest/platforms/android-35/android.jar",
        "ref:v0:92bf387f:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity/1.8.2/activity-1.8.2.jar",
        "ref:v0:a3ad1756:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity-compose/1.8.2/activity-compose-1.8.2.jar",
        "ref:v0:044e8f00:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/activity/activity-ktx/1.8.2/activity-ktx-1.8.2.jar",
        "ref:v0:812e5748:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui/1.3.3/ui-1.3.3.jar",
        "ref:v0:b1b4d426:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material3/material3/1.0.1/material3-1.0.1.jar",
        "ref:v0:5daf7830:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/runtime/runtime/1.3.3/runtime-1.3.3.jar",
        "ref:v0:62d3459a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/compose-runtime/0.1.0-dev14/compose-runtime-0.1.0-dev14.jar",
        "ref:v0:90d59983:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/core/core/1.9.0/core-1.9.0.jar",
        "ref:v0:96270a6b:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-runtime/2.6.1/lifecycle-runtime-2.6.1.jar",
        "ref:v0:926cc203:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-viewmodel/2.6.1/lifecycle-viewmodel-2.6.1.jar",
        "ref:v0:9d2f1237:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-viewmodel-savedstate/2.6.1/lifecycle-viewmodel-savedstate-2.6.1.jar",
        "ref:v0:d2d9f84d:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/profileinstaller/profileinstaller/1.3.0/profileinstaller-1.3.0.jar",
        "ref:v0:b319e818:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/savedstate/savedstate/1.2.1/savedstate-1.2.1.jar",
        "ref:v0:de7293d6:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/tracing/tracing/1.0.0/tracing-1.0.0.jar",
        "ref:v0:f67f5aac:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/runtime/runtime-saveable/1.3.3/runtime-saveable-1.3.3.jar",
        "ref:v0:705d0e01:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/core/core-ktx/1.9.0/core-ktx-1.9.0.jar",
        "ref:v0:9c420d5b:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-runtime-ktx/2.6.1/lifecycle-runtime-ktx-2.6.1.jar",
        "ref:v0:2d033b76:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-viewmodel-ktx/2.6.1/lifecycle-viewmodel-ktx-2.6.1.jar",
        "ref:v0:04d7f35a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/savedstate/savedstate-ktx/1.2.1/savedstate-ktx-1.2.1.jar",
        "ref:v0:be7eb18a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/autofill/autofill/1.0.0/autofill-1.0.0.jar",
        "ref:v0:84d7cf87:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-geometry/1.3.3/ui-geometry-1.3.3.jar",
        "ref:v0:00ef7172:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-graphics/1.3.3/ui-graphics-1.3.3.jar",
        "ref:v0:962a41c8:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-text/1.3.3/ui-text-1.3.3.jar",
        "ref:v0:6efd9175:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-unit/1.3.3/ui-unit-1.3.3.jar",
        "ref:v0:72ced6ff:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/ui/ui-util/1.3.3/ui-util-1.3.3.jar",
        "ref:v0:13046341:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/customview/customview-poolingcontainer/1.0.0/customview-poolingcontainer-1.0.0.jar",
        "ref:v0:bc358fdc:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/animation/animation-core/1.1.1/animation-core-1.1.1.jar",
        "ref:v0:b37dbefe:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/foundation/foundation/1.2.0/foundation-1.2.0.jar",
        "ref:v0:1d85bc42:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/foundation/foundation-layout/1.2.0/foundation-layout-1.2.0.jar",
        "ref:v0:b562c212:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material/material-icons-core/1.0.2/material-icons-core-1.0.2.jar",
        "ref:v0:3efd7380:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/material/material-ripple/1.0.0/material-ripple-1.0.0.jar",
        "ref:v0:cbcfaba2:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/annotation/annotation-experimental/1.3.0/annotation-experimental-1.3.0.jar",
        "ref:v0:827efd00:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/versionedparcelable/versionedparcelable/1.1.1/versionedparcelable-1.1.1.jar",
        "ref:v0:d4ca5f0a:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/arch/core/core-runtime/2.2.0/core-runtime-2.2.0.jar",
        "ref:v0:e0932eed:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/lifecycle/lifecycle-livedata-core/2.6.1/lifecycle-livedata-core-2.6.1.jar",
        "ref:v0:49dbce52:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/startup/startup-runtime/1.1.1/startup-runtime-1.1.1.jar",
        "ref:v0:bbe17a5c:/home/mrblacked/.cache/coursier/v1/https/maven.google.com/androidx/compose/animation/animation/1.1.1/animation-1.1.1.jar"
    ],
    "valueHash": -1260546939,
    "inputsHash": 1662969440
}

Error: #3696 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants