相关疑难解决方法(0)

如何在Android Studio中显示依赖关系树?

我的目标是在特定项目中查看依赖树(例如:appcompat,dagger等).

像一个IntelliJ:

在此输入图像描述

android intellij-idea gradle android-studio android-gradle-plugin

71
推荐指数
8
解决办法
6万
查看次数

Dagger-Hilt @AndroidEntryPoint 不适用于 BottomSheetDialogFragment()

我在 BottomSheetDialogFragmet() 中使用 ViewModel,所以我必须用 @AndroidEntryPoint 标记我的 BottomSheet。

\n
@AndroidEntryPoint\nclass SearchAddressDialog : BottomSheetDialogFragment() {\n\n    private val viewModel: MyAddressesViewModel by viewModels()\n    \n    ......\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但是当我尝试构建我的项目时,它给了我这个错误:

\n
Execution failed for task \':app:kaptDebugKotlin\'.\n> A failure occurred while executing \norg.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction\n> java.lang.reflect.InvocationTargetException (no error message)\n\n* Try:\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option \nto get more log output. Run with --scan to get full insights.\n
Run Code Online (Sandbox Code Playgroud)\n

这是我使用 --stacktrace 运行的输出

\n

https://gist.github.com/javlonrahimov/95de968645cace1dfb6e425381f8014b

\n

如果我删除 BottomSheetFragmen() 上方的 @AndroidEntryPoint,它将构建并安装应用程序。但是当我尝试打开 BottomSheet 时,当我将存储库注入 …

android gradle dagger-hilt bottomsheetdialogfragment

5
推荐指数
1
解决办法
4966
查看次数

Hilt java.lang.IllegalStateException:不支持的元数据版本。检查您的 Kotlin 版本是否 >= 1.0

我在项目中添加 hilt 依赖项时遇到问题

插件

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'realm-android'
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-parcelize'
}
Run Code Online (Sandbox Code Playgroud)

依赖关系

//Dependency injection with Hilt 
implementation("com.google.dagger:hilt-android:2.38.1")
kapt("com.google.dagger:hilt-android-compiler:2.38.1")
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Run Code Online (Sandbox Code Playgroud)

build.gradle 项目级别

buildscript {

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath "io.realm:realm-gradle-plugin:10.11.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0"
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.42"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' …
Run Code Online (Sandbox Code Playgroud)

android dependency-injection kotlin dagger-hilt

4
推荐指数
1
解决办法
5927
查看次数