When adding both Dagger 2 and Android Data Binding to my project I get some the below build time errors. It seems that this is a known problem (see [1] or [2]) as I get the exact same errors. Unfortunately I was not able to solve them (like some others). Does someone have a full working setup with current versions of Dagger 2 and Data Binding, and can help?
Here the errors:
C:\Users\Kai\AndroidStudioProjects\WearCompass\mobile\src\main\java\com\comparilla\wearcompass\ui\navigation\InfoPanelFragment.java:12: error: package com.comparilla.wearcompass.databinding does not exist
import com.comparilla.wearcompass.databinding.FragmentInfoPanelBinding;
^
C:\Users\Kai\AndroidStudioProjects\WearCompass\mobile\src\main\java\com\comparilla\wearcompass\ui\navigation\InfoPanelViewModel.java:8: error: cannot find symbol
import com.comparilla.wearcompass.BR;
^
symbol: class BR
location: package com.comparilla.wearcompass
C:\Users\Kai\AndroidStudioProjects\WearCompass\mobile\src\main\java\com\comparilla\wearcompass\MobileApplication.java:7: error: cannot find symbol
import com.comparilla.wearcompass.di.components.DaggerMobileApplicationComponent;
^
symbol: class DaggerMobileApplicationComponent
location: package com.comparilla.wearcompass.di.components
C:\Users\Kai\AndroidStudioProjects\WearCompass\mobile\src\main\java\com\comparilla\wearcompass\di\components\MobileActivityComponent.java:15: error: com.comparilla.wearcompass.common.services.HeadingService cannot be provided without an #Inject constructor or from an #Provides-annotated method.
void inject(InfoPanelFragment fragment);
^
com.comparilla.wearcompass.common.services.HeadingService is injected at
com.comparilla.wearcompass.di.modules.ActivityModule.provideInfoPanelViewModel(headingService, …)
com.comparilla.wearcompass.ui.navigation.InfoPanelViewModel is injected at
com.comparilla.wearcompass.ui.navigation.InfoPanelFragment.mViewModel
com.comparilla.wearcompass.ui.navigation.InfoPanelFragment is injected at
com.comparilla.wearcompass.di.components.MobileActivityComponent.inject(fragment)
4 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
My project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And the application build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.comparilla.wearcompass"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
wearApp project(':wear')
testCompile 'junit:junit:4.12'
// to enable BuildConfig.DEBUG in the common library
// see https://stackoverflow.com/a/29163361/166229
releaseCompile project(path: ':common', configuration: 'release')
debugCompile project(path: ':common', configuration: 'debug')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:preference-v14:24.0.0'
compile 'com.google.dagger:dagger:2.5'
apt 'com.google.dagger:dagger-compiler:2.5'
provided 'javax.annotation:jsr250-api:1.0'
}
I also tried to provided instead of apt in apt 'com.google.dagger:dagger-compiler:2.5', without success. Also commenting out apply plugin: 'com.neenbedankt.android-apt' did not help (like suggested in the provided resources).
I do have Dagger 2 and DataBinding configured in the same project and it's working without any problem.
You do have error in Dagger 2 configuration. The HeadingService you're trying to inject can't be created because you haven't provided it with #Provides annotation and also the class doesn't have #Inject annotation on constructor.
Related
I just Convert my project to androidX and project build successfully. But when I want to run that time it's created this error in android studio 3.5.3 with java enabled.
Here's my project gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
My module gradle file: All dependency I add here.
apply plugin: 'com.android.application'
android {
dataBinding {
enabled = true
}
compileSdkVersion 28
defaultConfig {
applicationId "com.exam.test"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
signingConfig signingConfigs.release
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
//Dependencies
dependencies {
api 'com.google.android.material:material:1.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-location:16.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
implementation 'androidx.biometric:biometric:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
googleServices.disableVersionCheck = true
Build output: Here pom details not download when running the application
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugAnnotationProcessorClasspath'.
> Could not resolve androidx.databinding:databinding-compiler:3.5.3.
Required by:
project :app
> Could not resolve androidx.databinding:databinding-compiler:3.5.3.
> Could not get resource 'https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler/3.5.3/databinding-compiler-3.5.3.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler/3.5.3/databinding-compiler-3.5.3.pom'.
> Remote host closed connection during handshake
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
these type of problems occure because of some library are not in harmoney with each other
then you should update maybe your problem will be gone .
i had same problem and now resolved it.
first upgrade your gradle
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip
second update your kotlin-plugin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
third update your android studio to last version 3.6 or higher
note : this part maybe show error then you should update your constraint layout
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3'
i hope you resolve it
Finally, I solved it by increasing internet speed.
It's because of internet issues. As regular internet, it's created problems. But when I increased internet speed now the problem is solved.
Now it's working properly.
I am implemented VirtualAPK library and failed to build project
My Project gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.didi.virtualapk:gradle:0.9.8.6'
// 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
}
Also I implemented library and applied as per library guide in Module gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.didi.virtualapk.host'
android {
compileSdkVersion 28
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.example.vspace"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.didi.virtualapk:core:0.9.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And after that I am trying to build project and getting Error like():
Compiling with JDK Java compiler API.
Created classpath snapshot for incremental compilation in 0.024 secs.
[INFO][VAHostPlugin] Used compileClasspath: debug
> Task :app:compileDebugJavaWithJavac FAILED
:app:compileDebugJavaWithJavac (Thread[Daemon worker,5,main]) completed. Took 2.586 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodException: No similar method computeBuildMapping with params [class org.gradle.invocation.DefaultGradle_Decorated] could be found on type class com.android.build.gradle.internal.ide.ModelBuilder.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
I was also tried to downgrade and upgrade gradle version and also tried with old Android Studio 3.0.1 and with 3.4.1. But nothing is working here. So, if any one can help then its surely acceptable.
I also refers This question but its can't helped me.
VirtualApk is doing this.....and computeBuildMapping is not supported(based on error in your post) in gradle 3.4.1.
if (project.extensions.extraProperties.get(Constants.GRADLE_3_1_0)) {
ImmutableMap<String, String> buildMapping = Reflect.on('com.android.build.gradle.internal.ide.ModelBuilder')
.call('computeBuildMapping', project.gradle)
.get()
compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null, buildMapping)
} else {
compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null)
}
so, try building your project with gradle plugin 3.1.0 and gradle version 4.4
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I was trying to add firebase auth to my android project but getting this error.
I have tried adding 'com.google.firebase:firebase-core:16.0.3' too but its taking more than 40 mins and still not syncing the gradle.
This is build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myaid.startup"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
This is app.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.1.0'
// 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
}
This is the error:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'MyAid'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.3.2.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
CONFIGURE FAILED in 2m 13s ERROR: Connection reset
I have resolved this problem by removing all my .gradle files, SDK files, .m2 files, .androidstudio files and then re-installing it.
Followed this answer: How to completely uninstall Android Studio
Please check your gradle's proxy settings. Enable it or disable it in the following file:
~/.gradle/gradle.properties
Like:
systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
Advices:
If your connection to repositories is not stable, use a proxy
instead of direct connection.
If you used to use a proxy for
gradle, check if it is still working.
i get this error when i make gradle online.
Error:Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'testClasses' not found in project ':ProwessPride_V1.01'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Where ProwessPride_V1.01 is the jar file which i include in project.
I do Invalidate Caches/Restart in studio. rebuild and clean project also but i can't resolve this error. So please help me how can i solve it.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.technopits.dcn"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.google.android.gms:play-services-gcm:7.3.0'
compile project(':ProwessPride_V1.01')
}
buil.gradle project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Defining compile project(':ProwessPride_V1.01'), gradle is searching for a project with the same name in the settings.gradle.
Since it is a jar it is wrong.
Just remove this line.
compile project(':ProwessPride_V1.01')
If you adding the jar in the libs folder, this line is enough for you.
compile fileTree(include: ['*.jar'], dir: 'libs')
Follow the steps:
Undo any changes you made while adding the library (remove any dependancies or JAR's)
Drag n Drop the jar file in libs folder (inside android studio)
Clean Build
I use Android Annotations in some other projects too. But in this it won't generate my files.
I try to migrate from Eclipse to Android Studio.
I'm also updating my libraries.
In Eclipse everything was working fine.
Note: Resolve log file to C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\build\generated\source\apt\androidannotations.log
Note: Initialize AndroidAnnotations 3.3.2 with options {androidManifestFile=C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\build\intermediates\manifests\full\debug\AndroidManifest.xml, resourcePackageName=at.flohmo}
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:14: error: cannot find symbol
import at.flohmo.AdvertDetailsActivity_;
^
symbol: class AdvertDetailsActivity_
location: package at.flohmo
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:15: error: cannot find symbol
import at.flohmo.AngeboteActivity_;
^
symbol: class AngeboteActivity_
location: package at.flohmo
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:16: error: cannot find symbol
import at.flohmo.ChatActivity_;
^
symbol: class ChatActivity_
location: package at.flohmo
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:17: error: cannot find symbol
import at.flohmo.MainActivity_;
^
symbol: class MainActivity_
location: package at.flohmo
warning: The following options were not recognized by any processor: '[androidManifestFile, resourcePackageName]'
4 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flohmoLI:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
here the gradle files:
project gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/urbanairship/android" }
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
mavenCentral()
}
}
app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'android-apt'
buildscript {
repositories {
mavenCentral()
}
dependencies {
// Since Android's Gradle plugin 0.11, you have to use android-apt >= 1.3
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName 'at.flohmo'
}
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "at.flohmo"
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
def AAVersion = '3.3.2'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.urbanairship.android:urbanairship-sdk:6.1.+'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile project(':flohmosimplecropimagelib')
compile project(':flohmoLibrarySlidingMenu')
compile project(':flohmoPullToRefreshLibrary')
compile files('libs/ADTECHMobileSDK.jar')
}
off-question: are there gradle projects for the last four compile requests?
I had the same problem I switched from repositories to be wrapped in allprojects block. That made it work.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I'll try to remove specific section apt... See my last question, may you find something useful.
I'm answer without computer in front ;)