Android Studio, cannot find symbol method from already added dependency - android

I have a weird problem when compiling my project in Android studio. I have two dependencies that kind of affect each other. When I have,
compile 'com.github.dbachelder:CreditCardEntry:1.4.7'
the project compiles fine and works great. However, if I add,
compile 'io.smooch:ui:latest.release'
and compile project again, the methods from firstly added dependency
(com.github.dbachelder:CreditCardEntry:1.4.7) cannot be found.
I attempted:
clean, rebuild, ./gradlew clean && ./gradlew build,Sync with Gradle Files,Closing Android Studio and re-opening,Invalidate caches & restart, I even tried to import the CreditCardEntry repo to project manually.
If, I remove the dependency
compile 'io.smooch:ui:latest.release'
Again project compiles fine and find the methods of CreditCardEntry dependency.
The error:
Error:(160, 16) error: cannot find symbol method clearForm()
Error:(161, 16) error: cannot find symbol method
setOnCardValidCallback(CardValidCallback)
Error:(163, 16) error:
cannot find symbol method focusCreditCard()
Any help appreciated..

io.smooch.ui actually contains com.devmarvel.creditcardentry as an embedded dependency, and it's using the same namespace. My first hunch would be that you have a namespace conflict.
This feels like a bug on the Smooch SDK side, the embedded dependency probably should be re-namespaced to avoid conflicts like this. (Disclaimer: I work on Smooch, I'll file a bug on our end)
An immediate workaround that might work is to remove your com.github.dbachelder:CreditCardEntry:1.4.7 package for now and see if you can resolve com.devmarvel.creditcardentry.CreditCardEntry and com.devmarvel.creditcardentry.CreditCardForm from the Smooch UI package instead.

Related

Library not adding its dependencies when used

I made a library, but when I tried to use it with implementation 'com.example:mylibrary:1.3.0' in my app's build.gradle, I keep getting an error saying the ConstraintLayout dependency (which the library uses but not the app) is not found. However it was explicitly defined in the library's build.gradle with implementation.
When I ran gradlew app:dependencies on the terminal, it shows that the library has no dependencies, even though it actually has 2. This seems to be the source of the problem, Gradle can't detect the dependencies of the library.
I didn't run into this problem for a while but when I decided to remove the ConstraintLayout dependency from my app an error appears during build.
When you're using implementation for the dependencies in your library, the project which is dependent with it will not see the dependencies. You need to use api instead of implementation.

Error when adding libraries on Android Studio

I'm trying to create an app for android (google Tango) that uses thrift to send some information to a client. I take a sample Tango app which runs without Thrift. Then when I add try to add some of the Thrift dependencies (like slf4j-log4j12-1.7.12.jar) I suddenly get errors like
error: package com.google.atap.tangoservice does not exist
I don't get what's wrong, it worked before...
Why does this happen, and how can I fix it?
Thank you
UPDATE
The way I added the library was by clicking right on App>new>module then I chose import jar, and selected the jar. Then I went to project structure and in dependencies I added the module of the jar I imported.
Adding it like this did not help me resolve the conflicts I had before:
import org.slf4j.Logger;
giving me the error "cannot resolve symbol 'Logger'".
And it also introduced the errors previously mentioned.
Have you tried adding a dependency to your build.gradle file like this:
dependencies {
compile 'com.google.atap.tangoservice'
}
If you are using local jar dependency then add it like this to the build.gradle:
dependencies {
compile files('libs/something_local.jar')
}

Efficient way to fix Gradle error “Attribute ”xxx“ has already been defined” in Android Studio?

In my project, i have a module abc:
//abc module (lib) dependency
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
And my app's dependency:
dependencies {
compile project(':abc')
}
And the errors are:
“Attribute ”mnp“ has already been defined”
“Attribute ”xyz“ has already been defined”
...
And i found that all these attributes are defined in declare-styleable of module abc and they are quite a lot. I dont know where they produce the duplicate since i can run normally from Eclipse, not Android Studio. Some suggests that to manually rename the attributes of those but I think it is time consuming.
Any better solution? Thank you!
This happens to me as well when I import project from Eclipse. Android Studio seems to binds library project even thou there was an error adding library modules.
I can usually fix this by firstly delete library modules, then opening Project's settings.gradle file and delete imports from there. After this, import of library modules works well.
And when I have issues with styleable file, I can usually fix this by setting SDK version to at least 20 (Android 5.0)

Android studio with actionbar sherlock, sliding menu and google play services

I am trying to export our eclipse based project to android studio. Our project is pretty complex and have a long list of dependencies. I used the eclipse based export and import to android studio worked fairly ok.
Currently my build.gradle has these dependencies based on https://stackoverflow.com/a/17243377/31252 and sample build.gradle file
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:19.0.+'
But I still seeing compilation errors failing on actionbarsherlock.
error: cannot find symbol class SherlockMapFragment
error: package com.google.maps.android.ui does not exist
error: cannot find symbol class SherlockMapFragment
I tried various combinations including
Tried an older play services 3.2+, this failed with problem in android manifest
Tried apklib in place of aar for actionbar sherlock
Tried - Gradle Error Could not find com.actionbarsherlock:actionbarsherlock:4.4.0 with Eclipse exported project in Android Studio
Also tried importing actionbarsherlock.jar generated elsewhere as jar file.
Import ABS project as a maven dependency module - this messed up my project structure big time.
But the above problem is still persistent. I also have slidingmenu that is throwing compile errors but first I want to tackle actionbarsherlock
Turns out there was a customization in the ABS project, I moved SherlockMapFragment class to our project and adjusted namespaces and this seem to work now

Gradle dependencies not imported into library project

Hey I've been trying for hours to import an Android library (BetterPickers latest commit) into my project using Gradle
After importing and setting it as module, I get compilation errors. It seems like something is wrong with dependencies in my build.gradle .
build.gradle of library project
build.gradle of main project
As you can see, Android Studio suggests an autofix but it's not helpful.
When I try to run the project/Gradle build, I get compilation errors since the library project is dependent on nineolddroids lib. When I try to add nineolddroids to the dependencies I get a different error:
Could not resolve all dependencies for configuration ':sub:bp:_DebugCompile'.
Could not find com.nineoldandroids:library:2.4.0.)
I guess both of them are derived from the same thing.
How can I fix this?
A few remarks
Using latest Android Studio (0.2.5)
Android Support Repository is installed
In the main project, the support lib is imported just fine and I get no compilation errors when using classes from support lib
Tried many ways to import the library project, including answers from here

Categories

Resources