I'm having a issue implement Hilt on android app...
The error is:
Expected #HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
Project gradle file
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
//Hilt
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
}
}
Model gradle file
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
dependencies {
def dagger_hilt_android = "2.38.1"
implementation("com.google.dagger:hilt-android:$dagger_hilt_android")
kapt("com.google.dagger:hilt-android-compiler:$dagger_hilt_android")
}
It is an issue with Kotlin-gradle-plugin: 1.5.20 as mentioned here https://github.com/google/dagger/issues/2684. Try upgrading your plugin to 1.5.21, and it will work.
Mohmd.h.bh,
Try applying this plugin in your build.gradle of your Android Gradle
apply plugin: 'com.google.dagger.hilt.android'
android {
// .......
}
I don't think you need to change the version of the kotlin-gradle-plugin
Regards
Related
In the new project Gradle plugin has a lot of changes and I can't add classpath for safe args. How I can solve this problem?
You can manually add this above plugins in your top level build.gradle
buildscript {
dependencies {
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2")
}
}
And in App level build.gradle
plugins {
id 'androidx.navigation.safeargs'
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
//classpath 'com.android.tools.build:gradle:3.2.0-alpha09'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.google.firebase:firebase-plugins:2.0.0'
/*classpath 'com.google.gms:google-services:3.2.1'
classpath 'com.google.firebase:firebase-plugins:1.2.0'*/
classpath 'com.google.guava:guava:24.1-jre'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
flatDir {
dirs '../libs'
}
google()
maven { url "https://jitpack.io" }
}
tasks.withType(JavaCompile) {
options.incremental = true
}
}
ERROR: Gradle DSL method not found: '19.0.0()'
Possible causes:
The project 'Rightrend-20190527-2051' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.5.0 and sync project
The project 'Rightrend-20190527-2051' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
I fix this error by adding this line to .gradle file (app)
Gradle DSL method not found: 'kapt()'
Possible causes:
The project 'Isfahan Metro' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.5.3 and sync project
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' // add this
for your problem check this link.
https://stackoverflow.com/answer
move google() above.
Open your gradle-wrapper.properties file, and update distributionUrl to https://services.gradle.org/distributions/gradle-5.4.1-all.zip
This is the wrongful line, because Guava is not a Gradle plugin:
classpath 'com.google.guava:guava:24.1-jre'
In "classpath" alter for "implementation" (update your dependencies):
dependencies {
implementation'com.android.tools.build:gradle:3.5.0'
//implementation'com.android.tools.build:gradle:3.2.0-alpha09'
implementation'com.google.gms:google-services:4.3.2'
implementation'com.google.firebase:firebase-plugins:2.0.0'
/*implementation'com.google.gms:google-services:3.2.1'
implementation'com.google.firebase:firebase-plugins:1.2.0'*/
implementation'com.google.guava:guava:24.1-jre'
}
In my app module's build.gradle, I have added
dependencies {
kapt('com.android.databinding:compiler:3.1.2')
...
}
but I'm still receiving the compiler warning for
app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.android.databinding:compiler:3.1.2'.
Everything functions, I just hate having warnings hanging around.
Any help is much appreciated!
I had same warnings until I upgraded to the latest Android Gradle build plugin and Kotlin. Now they are gone. Here is the configuration I use.
project.gradle
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51"
}
}
module.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
...
dataBinding {
enabled = true
}
}
dependencies {
// no kapt declaration for databinding here
}
Hope it helps.
Add following in you app build.gradle
kapt "com.android.databinding:compiler:$android_plugin_version"
apply plugin: 'kotlin-kapt' // This one at top where plugin belong to
This will do the trick.
$android_plugin_version is version of com.android.tools.build:gradle in application build.gradle
Also, add this to your module build.gradle
android {
/// Existing Code
kapt {
generateStubs = true
}
}
You are missing apply plugin: 'kotlin-kapt' i think.
Changing the build.gradle
and then I run cordova build android the build.gradle file is updated.
How can I change the dependencies of cordova / plugins? Or force to a particular version?
Having issues with : google-gcm services
I am having conflicting dependencies of plugin causing the services to fail to build.
Something like this might help you :
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}
Recently i have updated Android studio from 1.5.1 to 2.0, after updation it asked me to use latest gradle i.e. com.android.tools.build:gradle:2.0.0
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
But after updating it is showing error with DataBinding plugin.
apply plugin: 'com.android.databinding' //error on this line
Error message :
Error:(2, 0) Cause: org/apache/commons/lang3/StringUtils
Open File
I have not used any apache library or any deprected apache classes.
UPDATE :
Harshad's answer helped me, so final conclusion is we don't need to add those plugins with gradle 2.0.+
classpath "com.android.databinding:dataBinder:1.0-rc1" remove
apply plugin: 'com.android.databinding' remove
This may be help you.
You can just remove these two lines of code:
apply plugin: 'com.android.databinding'
And this one in buildscript's dependencies:
classpath 'com.android.databinding:dataBinder:1.0-rc1'
Then add the dataBinding section to your build.gradle like this.
buildscript {
...
}
android {
...
dataBinding {
enabled = true
}
...
}
dependencies {
...
}