I am trying to include the HoloColorPicker library (or for that matter any other library in my project), however, I cannot seem to get it to download.
The dependency section in my build.gradle file looks like:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.android.support:support-v13:21.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5+'
wearApp project(':Wearable')
The error message I get is as follows:
What went wrong: A problem occurred configuring project
':Application'. Could not resolve all dependencies for configuration
':Application:_debugCompile'.
Could not find any version that matches com.larswerkman:HoloColorPicker:1.5+.
Searched in the following locations:
file:/Users/Tom/Library/Android/sdk/extras/android/m2repository/com/larswerkman/HoloColorPicker/maven-metadata.xml
file:/Users/Tom/Library/Android/sdk/extras/android/m2repository/com/larswerkman/HoloColorPicker/
file:/Users/Tom/Library/Android/sdk/extras/google/m2repository/com/larswerkman/HoloColorPicker/maven-metadata.xml
file:/Users/Tom/Library/Android/sdk/extras/google/m2repository/com/larswerkman/HoloColorPicker/
Required by:
watchfaces2.0:Application:unspecified
I cannot seem to figure out why Android Studio is looking for the library under my local path as opposed to pulling the library down from the internet. How can I get past this issue?
Have you included Maven in your gradle file?
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.android.support:support-v13:21.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5+'
wearApp project(':Wearable')
}
Just for complete the picture:
dependencies {
repositories {
mavenCentral()
}
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.android.support:support-v13:21.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5+'
wearApp project(':Wearable')
}
Related
I'm trying to exclude a class from jar, but it doesn't work.
Let me know hot to do it.
This is my code:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.google.android.gms:play-services-gcm:8.3.0') {
exclude module: 'com.google.android.gms.iid/zzb'
}
compile 'org.xwalk:xwalk_core_library:14.43.343.17'
compile 'com.google.code.gson:gson:2.4'
compile 'commons-io:commons-io:2.4'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
compile project(":adjust")
}
This is the error message:
Error:Execution failed for task ':app:packageAllReleaseClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzb$zza$zza.class
In plain Gradle, what you are looking for can be achieved as:
dependencies {
compile('com.example.m:m:1.0') {
exclude group: 'org.unwanted', module: 'x
}
compile 'com.example.l:1.0'
}
This would exclude the module X from the dependencies of M, but will still bring it if you depend on L.
I am doing an android-library using Gradle and its build successfully, but when I open some class that uses this dependency not resolve sysmbols. Why?
In my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
//myDependency
compile project(':myDependency')
}
Thanks.
Ps. My dependency is a pure Java project
Immediately after adding the facebook-audience-network-sdk in my gradle file, I started getting errors, the first one I fixed my adding multiDexEnabled true, after that I keep getting this error
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqa.class
Here are my dependencies list in build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
compile 'com.facebook.android:audience-network-sdk:4.10.0'
compile 'joda-time:joda-time:2.7'
}
After running gradle with -q dependencies here is my screenshot, I think the problem is related to google play services libraries seeing the facebook.android:audience-network-sdk depends on analytics 7.8.0 while I have included the latest 8.4.0 already in my dependencies, I'm not sure.
How can i fix this?
I finally got rid of the error. So the problem was with the com.google.android.gms:play-services-ads-8.1.0. You can see from the image it was 8.1.0 and other play dependencies were 8.4.0.
So these two ways worked. One was to change the dependency into
compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
exclude group:"com.google.android.gms"
}
But the issue with this is that, it could be a problem since in my other dependencies I didn't have play-services-ads:8.4.0'
So the way I solved this was just add a single line
compile 'com.google.android.gms:play-services-ads:8.4.0'
This way everything worked perfectly, because when gradle compiled it automatically replaced the 8.1.0 into the 8.4.0
Here is my final dependencies list that worked
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
compile 'com.facebook.android:audience-network-sdk:4.10.0'
compile 'joda-time:joda-time:2.7'
}
I am a freshman in android development and want to use webservice by some jars.(The webservice has been written and publish).
Then I use Ksoap.jar and Jsoup.jar.
In android studio. I try to import them. It shows successful but I still cannot use the classes in the jars.
The build.gradle shows below:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile files('libs/ksoap2-android-3.4.0.jar')
compile files('libs/jsoup-1.8.3-sources.jar')
}
But in my activity, I still cannot import them.
How can I solve this problem?
It drives me mad.
You don't need
compile files('libs/ksoap2-android-3.4.0.jar')
compile files('libs/jsoup-1.8.3-sources.jar')
As long as you have those jar files in the libs folder, this gradle line will include them in your project.
compile fileTree(dir: 'libs', include: ['*.jar'])
It says "for every jar file in the libs/ directory, compile it." Having those two additional lines is redundant.
In my project, use the library MaterialDesign. When I add also the library MPchart, I get this error and do not understand what's wrong. Thank You
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
build.gradle of MaterialDesign Library:
dependencies {
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.android.support:support-v4:21.0.3'
}
and build.gradle of project:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.nineoldandroids:library:2.4.+'
compile project(":MaterialDesign")
compile project(":MPChartLib")
compile files('libs/opencsv-2.4.jar')
}.
If I remove the dependence, I get other errors.
What can I do?
It seems that you are declaring a dependency com.nineoldandroids:library:2.4.+ in both MPChartLib and in your project. This is what's causing the problem.
Try to remove the dependency from your project but leave it in MPChartLib so that the dextool only sees it once. Your new build.gradle would look like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile project(":MaterialDesign")
compile project(":MPChartLib")
compile files('libs/opencsv-2.4.jar')
}
Also do the same for the Android support library. It should be declared only once or you'll get similar errors.