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

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

Related

Android Studio, cannot find symbol method from already added dependency

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.

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 Could not find class 'org.apache.commons.scxml.env.jexl.JexlContext'

I'm using apache commons SCXML to define a state machine my Android app. In my Android Studio project, I've added the following in the dependencies section of my build.gradle file:
compile 'commons-scxml:commons-scxml:0.9'
compile 'commons-logging:commons-logging:1.1.3'
compile 'org.apache.commons:commons-jexl:2.1.1'
Unlike the answer to this question, I cannot add xalan as it tries to overwrite Android system files, leading to this error.
I then clicked the 'Sync Project with Gradle Files' button, and the commons-scxml and commons-jexl files showed up in the "external dependencies" section of my project.
However, when I run my app, I still get this error:
Could not find class 'org.apache.commons.scxml.env.jexl.JexlContext', referenced from method org.apache.commons.scxml.env.AbstractStateMachine
You also need org.apache.commons:commons-jexl:1.1 as a dependency.

Why Android Studio can't reference a library if included in build.gradle only?

In my app I'm using Guava library. I have referenced it in my build.gradle file only as follows:
dependencies {
compile 'com.google.guava:guava:13.0.1'
}
My app rebuilds and runs fine. However when I'm trying to add a new something from Guava library then the compiler complains that it can't find the class.
For example: when I write
import com.google.common.base.Preconditions
in my new file the compiler says 'cannot resolve symbol common'.
But my old files are rebuilt fine. How so? Do I have to mess with Project|Structure? I specifically wanted to list any dependencies -only- in build.gradle.
It seems that doing a "sync project with gradle files" helps.
In Android Studio, select :
Tools > Android > Sync project with gradle files

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