相关疑难解决方法(0)

未找到 DefaultActivityViewModelFactory

将 Hilt 版本从我的项目迁移2.33-beta2.35我的项目后,已停止构建并出现以下错误:

在此处输入图片说明

一个txt版本:

error: cannot access DefaultActivityViewModelFactory    
  class file for dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory not found   
  Consult the following stack trace for details.    
  com.sun.tools.javac.code.Symbol$CompletionFailure: class file for dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory not found
Run Code Online (Sandbox Code Playgroud)

我的 build.gradle(项目)的一个片段:

buildscript {
    ext.hilt_version = '2.33-beta'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
        ...
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

我的 build.gradle (app) 的一个片段:

apply …
Run Code Online (Sandbox Code Playgroud)

android android-viewmodel dagger-hilt

11
推荐指数
3
解决办法
2646
查看次数

错误:类型不兼容:NonExistentClass无法转换为Annotation @ error.NonExistentClass()

我正在尝试生成我的项目的Doka文档。在生成时,出现了上述错误。我搜索了很多,但无法获得解决方案。我也通过这个链接。在这里说这可能是与匕首有关的问题。我也尝试了所有这些解决方案,但不适用于我。我将所有Gradle文件发布在此处,以进行进一步说明。如果有人遇到此问题或知道解决方法,请发表评论。

项目摇篮:

 buildscript {
        ext.kotlin_version = '1.3.20'
        ext.dokkaVersion = '0.9.17'
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokkaVersion"
            classpath "org.jetbrains.kotlin:kotlin-allopen:1.3.20"

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            google()
            jcenter()
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }
Run Code Online (Sandbox Code Playgroud)

应用程式摇篮:

    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'
apply plugin: 'org.jetbrains.dokka-android'

android { …
Run Code Online (Sandbox Code Playgroud)

android kotlin dagger-2 kotlin-dokka

6
推荐指数
0
解决办法
1628
查看次数

Kotlin&Dagger属于一起吗?

依赖注入可能是它们中最强大的模式,但是当我与Kotlin结合时,我想知道Dagger是否可靠,最重要的是可调试性足以处理大型项目.作为gradle中这条指令的一个例子

  kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
Run Code Online (Sandbox Code Playgroud)

产生一个非常长但无用的消息无法访问NonExistent类:缺少当然是如此困难的信息1)缺少的类的名称2)关于此引用所在的代码中的点的任何信息.

显然,这是2016年报告的旧问题:https: //github.com/google/dagger/issues/435

要解决这个问题,需要在此处概述两个步骤: ERROR:error.NonExistentClass Kotlin在多模块Dagger项目中

请记住,您可以在没有多模块情况下出现此错误.

对我来说,禁止在Kotlin应用程序中使用Dagger.我错过了什么或使用了错误的版本.我也把我的整个gradle文件附在下面!

      Error:17:18:39.263 [ERROR] [system.err] warning: Supported source version 'RELEASE_7' from annotation processor '__gen.AnnotationProcessorWrapper_debug_android_arch_persistence_room_RoomProcessor' less than -source '1.8'
        17:18:39.263 [ERROR] [system.err] error: cannot access NonExistentClass
        17:18:39.263 [ERROR] [system.err]   class file for error.NonExistentClass not found
        17:18:39.263 [ERROR] [system.err]   Consult the following stack trace for details.
        17:18:39.267 [ERROR] [system.err]   com.sun.tools.javac.code.Symbol$CompletionFailure: class file for error.NonExistentClass not found

        17:18:39.363 [ERROR] [system.err] 1 error
        17:18:39.363 [ERROR] [system.err] 1 warning
        17:18:39.399 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
        17:18:39.403 [ERROR] …
Run Code Online (Sandbox Code Playgroud)

android kotlin

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

构建 Android 应用程序时如何从 gradle 生成 OpenAPI 源

我正在努力实现的目标

我正在尝试使用build.gradle脚本中的OpenAPI Generator 为 Android 生成我的 REST API 客户端。这样,每次规格更改时我都不必运行生成器命令行。理想情况下,这将在我构建/组装我的应用程序时生成,并且源代码最终会在java (generated)文件夹中,然后可以从代码访问生成的源代码(例如BuildConfig.java文件会发生这种情况)。

到目前为止我尝试过的

按照他们官方 GitHub 上的这个链接,这是我最终得到的build.gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'org.openapi.generator'

...

openApiValidate {
    inputSpec = "$rootDir/app/src/main/openapi/my-api.yaml"
    recommend = true
}
openApiGenerate {
    generatorName = "java"
    inputSpec = "$rootDir/app/src/main/openapi/my-api.yaml"
    outputDir = "$buildDir/generated/openapi"
    groupId = "$project.group"
    id = "$project.name-openapi"
    version = "$project.version"
    apiPackage = "com.example.mypackage.api"
    invokerPackage = "com.example.mypackage.invoker"
    modelPackage = "com.example.mypackage.model"
    configOptions = [
        java8               : "true",
        dateLibrary         : "java8", …
Run Code Online (Sandbox Code Playgroud)

android gradle openapi openapi-generator

5
推荐指数
2
解决办法
1237
查看次数

找不到 protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe (io.grpc:protoc-gen-grpc-kotlin:1.0.0)

我想使用 protoc-gen-grpc-kotlin 中的protoc-gen-grpc-kotlin -1.0.0并且我得到了

\n
Execution failed for task \':generateProto\'.\n> Could not resolve all files for configuration \':protobufToolsLocator_grpckt\'.\n   > Could not find protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe (io.grpc:protoc-gen-grpc-kotlin:1.0.0).\n     Searched in the following locations:\n         https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-kotlin/1.0.0/protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe\n\nPossible solution:\n - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html\n
Run Code Online (Sandbox Code Playgroud)\n

整个堆栈跟踪是

\n
C:\\_d\\toLearn\\demo-grpc-jaeger>gradle clean build --stacktrace\n> Task :generateProto FAILED\n\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nExecution failed for task \':generateProto\'.\n> Could not resolve all files for configuration \':protobufToolsLocator_grpckt\'.\n   > Could not find protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe (io.grpc:protoc-gen-grpc-kotlin:1.0.0).\n     Searched …
Run Code Online (Sandbox Code Playgroud)

gradle kotlin grpc protoc micronaut

3
推荐指数
1
解决办法
2756
查看次数