gradle maven dependencies proguard trouble - android

In my build.gradle
dependencies {
compile "com.android.support:support-v4:18.0.+"
compile fileTree(dir: 'libs', include: '*.jar')
compile project(":Vendor:NineOldAndroids:Library")
compile project(":Vendor:Unionpay:upomp_Res_v1_1")
compile project(":Vendor:ViewPagerIndicator:Library")
compile project(":Vendor:SlidingMenu-library")
}
I have a dependency support-v4, it's a maven-repo(Why don't I include support-v4.jar directly? I think maven-repo a better way manage dependencies, it's easy to avoid to include support-v4 many times)
But a trouble comes up, I need proguard my project, maven-repo makes me can't set -libraryjars 'libs/android-support-v4.jar' because the support-v4 is in somewhere "dynamically"
I can't find an official way to to this, anyone can solve it ?

Related

Android Eclipse : How to resolve third party library dependencies corresponding to gradle build

I am porting an android application project built with non-eclipse tool, with gradle in use, perhaps the tool was Android Studio. I have the .zip file of the project. So, far I have put all layout,values and drawables in place. I am stuck at the last step of dependencies.
The project depends on Github : BlueJamesBond library and many others. This is the build.gradle dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile "com.android.support:support-v4:+"
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
}
Now, the BlueJamesBond itself is using gradle and I have no idea how gradle works. I was expecting some jar of the library which I could have added in Build Path. Can anyone please suggest how to resolve the dependency in my project?

Transitive Library dependencies are not found in the application

Say I have a library module which contains some 3rd party libraries like OkHttp. When I include this library in my application I was unable to use these 3rd party libraries. I read the following articles Article 1,
Article 2
and tried
1. compile project(':library-name')
{after importing the .aar file(of library) as a module into myproject}
2. I included the .aar file in libs folder and added following dependencies
build.gradle(project level)
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
build.gradle(application level)
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ('com.myapp.package:library-name:1.0.0#aar'){
transitive=true
}
3. similar to 2nd but in
build.gradle(application level)
compile fileTree(dir: 'libs', include: ['*.jar'])
compile (name:'library-name', ext:'aar'){
transitive=true
}
But, still I was unable to use the transitive libraries which are present in my library. I am getting following exception.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/MediaType;
Can someone help
EDIT:
The following is build.gradle of my library
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'com.squareup.okhttp:okhttp:2.6.0'
compile 'petrov.kristiyan.colorpicker:colorpicker-library:1.0.3'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.hamcrest:hamcrest-library:1.1'
compile files('notificationlog-0.1.0.jar')
I was able to use the notificationlog in my application which was a dependency in my library, but I was unable to use okhttp and colorpicker
The aar file doesn't contain the nested (or transitive) dependencies and doesn't have a pom file which describes the dependencies used by the library.
It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.
It doesn't make sense:
compile (name:'library-name', ext:'aar'){
transitive=true
}
because the aar is without a pom file which describes the dependencies, then gradle is unable to add any dependencies because it can't know them.

NoClassDefFoundError: com.firebase.ui.auth.google.GoogleAuthProvider

I'm using Android Studio 1.5 and trying to add Firebase UI library to my application.
I've added it to my dependencies.
For some reason I'm getting the NoClassDefFoundError exception.
I've read that I should add Firebase-UI jar to my 'libs' folder, but I can't find it.
Any suggestions?
Most likely your missing the Google Play Services dependency from your app's build.gradle. For reference, this is one of mine:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebaseui:firebase-ui:0.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
}
FirebaseUI depends on com.google.android.gms:play-services-auth:8.3.0 for its Google authentication. For all dependencies, see this section of the README.

Multi dex files define Lcom/google/gdata/util/common/base/Escaper

Multi dex files define Lcom/google/gdata/util/common/base/Escaper
I am stuck with the above error. The error ocured after i have added a dependency to the UserVoice SDK
compile 'com.uservoice:uservoice-android-sdk:+'
since i added this dependency i am unable to run my Android project.
I have read about the jarjar command could probably solve this issue. But since the dependency are .aar librararies i do not know what could be the possible solution
any help is greatly appreciated
List of other depedencies:
compile('com.crashlytics.sdk.android:crashlytics:2.1.0#aar') {
transitive = true;
}
compile('com.twitter.sdk.android:twitter:1.1.0#aar') {
transitive = true;
}
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
compile 'com.squareup.retrofit:retrofit:1.7.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.melnykov:floatingactionbutton:1.0.5'
compile 'com.balysv.materialmenu:material-menu-abc:1.+'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5#aar'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile 'com.joanzapata.android:android-iconify:1.0.8'
compile 'com.squareup:otto:1.3.5'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:cardview-v7:21.+'
Gradle depdencies pastebin: http://pastebin.com/0m6b8Wyi
The problem you are having is caused by the fact that you have two dependencies that include the Escaper class. These are most likely dependencies of your dependencies so it's not obvious which one includes that class. You can be sure that com.uservoice:uservoice-android-sdk:+ includes the class Escaper as that is when your error occurs.
You can fix this problem by excluding the dependency from one of your compile dependencies. Take a look at the Gradle docs and scroll down to where it talks about "Excluding transitive dependencies". One thing to be careful of is the fact that the dependencies might be different versions but contain the same class. You should confirm that both libraries will work with the same version of the Escaper class.

difference between compile vs compile tree vs compile Files?

I was trying to integrate my project in android studio. but i am little confused when adding dependencies. I don't know which one is works good.I have tried Compile fileTree and compile files.Its not working for me . I found some methods.can any one tell me which one is appropriate for adding library (jar file only like admob).
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:+'
compile project(":libraries:libraryname")
compile files('libs/libraryname.jar')
can any one tell me which one is appropriate for adding library (jar file only like admob).
If the library is available as an artifact in a Maven or Ivy repository, like Maven Central, add the repository to your repositories block (e.g., mavenCentral()) and then use compile 'com.android.support:appcompat-v7:+', replacing the quoted string with the one that identifies the artifact that you want.
If the library is not available as an artifact, put the JAR in the appropriate directory (e.g., libs/ at the project level) and use compile fileTree(dir: 'libs', include: '*.jar').
compile project(":libraries:libraryname") is for sub-projects, which you probably do not have.
compile files('libs/libraryname.jar') works, but compile fileTree(dir: 'libs', include: '*.jar') is more flexible, as you do not have to change your build.gradle file for every JAR.

Categories

Resources