简体   繁体   English

Jetpack Compose 现有多模块应用程序中的依赖项

[英]Jetpack Compose dependencies in existing Multi-Module app

I'm facing issues while integrating jetpack compose in a multi-module project.我在将 jetpack compose 集成到多模块项目中时遇到了问题。

One module library has all the dependencies for jetpack compose, and I am able to compile and Run the jetpack compose code written inside that module.一个模块库具有 jetpack compose 的所有依赖项,我能够编译和运行编写在该模块内的 jetpack compose 代码。

 android {
    ...
   kotlinOptions {
      jvmTarget = '1.8'
      useIR = true
   }

   buildFeatures {
      compose true
   }

   composeOptions {
      kotlinCompilerExtensionVersion compose_version
      kotlinCompilerVersion '1.4.21'
   }
 }


dependencies {
   ...
   implementation "androidx.compose.ui:ui:$compose_version"
   implementation "androidx.compose.material:material:$compose_version"
   implementation "androidx.compose.ui:ui-tooling:$compose_version"
   ...
}

Where compose_version = '1.0.0-alpha09'其中 compose_version = '1.0.0-alpha09'

Issue comes when I add that library module into app module and integrate the jetpack compose there.当我将该库模块添加到应用程序模块并在那里集成jetpack compose时,问题就出现了。 It requires to add all the dependencies inside app module's build.gradle.kts file also.它还需要在 app 模块的 build.gradle.kts 文件中添加所有依赖项。

After adding same code of lines, gradle task (:app:compileDebugKotlin) keeps running in infinite loop without any error message.添加相同的代码行后,gradle 任务 (:app:compileDebugKotlin) 继续无限循环运行,没有任何错误消息。

What i am doing wrong here?我在这里做错了什么? any help would be appreciable.任何帮助都将是可观的。 Thanks!谢谢!

Update-1 Running gradlew compileDebugKotlin --debug, It stuck with below stack-trace Update-1运行 gradlew compileDebugKotlin --debug,它卡在下面的堆栈跟踪

2020-12-30T12:26:42.079+0530 [DEBUG] 
[org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on 
daemon addresses registry.
2020-12-30T12:26:42.079+0530 [DEBUG] 
[org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire 
shared lock on daemon addresses registry.
2020-12-30T12:26:42.080+0530 [DEBUG] 
[org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on 
daemon addresses registry.
2020-12-30T12:26:42.080+0530 [DEBUG] 
[org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on 
daemon addresses registry.

I've had a very similar problem, exactly the same stacktrace.我有一个非常相似的问题,完全相同的堆栈跟踪。 In my case it was caused by kotlin synthetic (android-kotlin-extensions) plugin.在我的情况下,它是由 kotlin 合成(android-kotlin-extensions)插件引起的。 Removing the plugin (as suggested in Adding buildFeatures { compose true } causes build to take indefinitely. How to investigate issue? ) resolved the issue.删除插件(如添加 buildFeatures { compose true } 中的建议会导致构建无限期进行。如何调查问题? )解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM