English 中文(简体)
Hilt一体化坠毁申请 主要活动——遗传工程
原标题:Hilt integration crashes application MainActivity_GeneratedInjector
最佳回答

Solved it by adding missing dependency for androidx hilt.

kapt  androidx.hilt:hilt-compiler:1.0.0-alpha01 

在我的梯度档案中,我有其他受扶养人。

implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02"
implementation  com.google.dagger:hilt-android:2.28-alpha 
kapt  com.google.dagger:hilt-android-compiler:2.28-alpha 
implementation "androidx.fragment:fragment-ktx:1.2.5"

Plus fragment and its activity who are injecting viewmodel using hilt both are annotated as @AndroidEntryPoint

问题回答

What worked for me:

  1. Removed the @AndroidEntryPoint annotation from the activity.
  2. Ran the code and of course, it failed.
  3. Had a fragment inside the activity. So, I deleted the fragment code as well.
  4. Ran the code, it failed.
  5. Added the @AndroidEntryPoint annotation to the activity again.
  6. Ran the code. It ran and the error disappeared.

作为对我来说,作为我在<处>的扶养声明,build.gradle,即必须使用<>api而不是><>>:

api Project (:features:feed Module >

更多学习:

Update: Dagger team released classpath aggregation feature which can resolve this issue. You can learn more here: https://dagger.dev/hilt/gradle-setup#classpath-aggregation

基本上,在你的评价模块build.gradle上,你需要补充:

hilt {
    enableExperimentalClasspathAggregation = true
}

如果在项目中使用的 Android平金字本少于7.0,确保也能够增加。 格勒布档案:

android {
    ...
    lintOptions {
        checkReleaseBuilds false
    }

在我的案件中,我收到了类似的<编码>。 由于我<代码>的模块 HiltAndroid App 对应班子可以进入我的@AndroidEntryPoint活动所在的模块。 将我的应用类别移至配套模块(能够进入所有其他格拉门模块)解决了这一问题。

https://developer.android.com/training/dependency-injection/hilt-android#hilt-modules” rel=“noreferer”

由于Hilt公司的代码生成需要进入使用Hilt的所有格拉斯模块,因此汇编你的应用等级的格拉斯模块也需要有你的所有功能。 在其过境附属地的Hilt模块和构造班。

我花了几个小时的时间来确定这一准确问题,但通过对所有单元进行无效的切身/重塑和重新建设来解决。

This is related to this issue from Hilt: Hilt: More meaningful error messages

即使该法典正确,但有时大错不行。

一种可能的解决办法是,将这一类重新命名为“Class2”类,重新开具,并检查它是否奏效。 如果工作,则将班级重新命名为原班。

这是通过无效的海滩和重新启动解决的。

我也存在同样的问题,这里我采取了以下步骤:

  1. appModule starts with internal enter image description here

  2. 在您的级别上建设。 甲型六氯环己烷

       enableExperimentalClasspathAggregation = true
    }
    
    
  3. 我的依托是:

    
    classpath "com.google.dagger:hilt-android-gradle-plugin:2.40.5"
    
        app-level build.gradle: 
         top plugin section
    
     plugin{
      ...........
      id  kotlin-kapt 
      id  dagger.hilt.android.plugin 
     }
    
         dependencies section
         //dagger-hilt
     implementation  com.google.dagger:hilt-android:2.40.5 
     kapt  com.google.dagger:hilt-android-compiler:2.40.5 ```
    

这是一种真正的sil性解决办法,但只是对注射通知和投放场发表评论,然后管理 app,并再次运行。

It s also happened to me when I m importing an .aar with "implementation". (an .aar which includes hilt)

一样,你不使用“api”增加汇编时间,而是可以在你的建筑中添加以下内容。 梯度(申请)

hilt {
    enableAggregatingTask = true
}

enableExperimentalClasspathAggregation 现在已经做了解释,

I was having the same java.lang.ClassCastException after adding Hilt. Steps to fix the problem:

1. Build -> Clean Project
2. Build -> Rebuild Project

另外,卡普切特也没有工作。 仅添加一个图形:

id  dagger.hilt.android.plugin 

然后,增加Hilt Dependcies:

implementation "com.google.dagger:hilt-android:2.38.1"
annotationProcessor "com.google.dagger:hilt-compiler:2.38.1"

www.un.org/Depts/DGACM/index_spanish.htm 需要采取的步骤:

  • Remove .gradle file in app s directory
  • Invalidate cache and restart android studio

希望它将解决你的问题。

对我来说,我原想把@AndroidEntryPoint<>/code>添加到一个叫作第二个活动的母体活动上,另一个叫作碎块。 显然,他们每个人都需要@AndroidEntryPoint

你可以删除你身上的fold,并删除你系统中的梯度。

rm -rf app/build

rm -rf ~/.gradle/caches/build-cache-1

仅仅拆除建筑的海滩比拆除所有的陈列室。

在我的案件档案中,这套材料没有包含,因此无法绘制档案,无法在制作的夹中生成。 因此,<代码>hilt无法解决档案。

I added the package in the fragment, and it resolve my issue

“enterography

在我的案件中,我是两度 setting子,造成了错误:

(a) 在安乐施会档案中:

    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustNothing"
        tools:ignore="LockedOrientationActivity">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <nav-graph android:value="@navigation/navigation_app_graph" />
    </activity>

活动一度——主轴:

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/navigation_app_graph"
        tools:ignore="UnusedIds"
        tools:layout="@layout/fragment_mosaic" />

活动标的内线的导航图为主要活动确定导航图。 这正是你为这一活动配置导航图的地方。

您可以删除其他定义,该定义是内部的;androidx.fragment.app.FragmentContainerView>

app:navGraph="@navigation/navigation_app_graph"

After all, the navigation graph has already been defined for the main activity, and you don t need to define it again inside the FragmentContainerView.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签