When I use compile 'xxx' to add a dependencies, an error message as follows:
what's wrong?
google's support-v4 is ok.
Hope someone can help me...
Thanks.
Gradle build system must resolve 'com.squareup.dagger:dagger:1.2.2' from somewhere.
In your case, looks you miss the following configuration in your gradle file.
repositories {
mavenCentral()
}
Then gradle will try to resolve the dependency from MavenCentral.
Of course, you can specify your own repository like this.
repositories {
maven {
url "http://repo.mycompany.com/maven2"
}
}
I make a new Android Studio project, it's ok to add dependencies with compile 'xxx'.Maybe the reason is the current project is import from Eclipse.
Related
I have uploaded .aar without pom.xml to artifactory and thus cannot load the library using gradle.
I would be grateful if you tell me or show how it should look inside the pom.xml.
If someone knows how to create the desired content file, then it will be great.
I tried to create pom.xml using the code in gradle below, but it seems to me that this is the wrong option.
task writePom {
doLast {
pom {
project {
groupId 'com.someth.someth'
artifactId 'name'
version '1.1'
url="http://someth.com/artifactory/someth_pr/someth-release.aar"
}
}.writeTo("pom.xml")
}
}
I used url to show where to get my .aar file.
When I put my generated pom.xml file in artifactory and decided to do "Sync now" gradle gave an error:
Failed to resolve: com.someth.someth:name:1.1
From Android Gradle plugin 3.6.0 and higher you can use the afterEvaluate{} publishing which allows you to publish build artifacts to an Apache Maven repository. It includes all the components for each build variant artifact in your app or library module (with the generated pom.xml).
More info you can find in the official Android documentation.
Have in mind that the repositories tag inside the pom.xml file (if you want to import dependencies from a custom source) it's skipped by the Android's gradle tasks for security reasons.
Last, you could use also the old classic way for the publication described by the JFrog official documentation.
I want to use this library in my project: https://github.com/haldertaer/android-maps-utils
When I use implementation 'com.github.haldertaer:android-maps-utils:0.5' in Gradle, I get the following error: ERROR: Failed to resolve: com.github.haldertaer:android-maps-utils:0.5
And, yes, I already have this:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
How can I fix this error? I do not see what's wrong.
As per the project documentation, the correct way to define the dependency for the official library is
implementation 'com.google.maps.android:android-maps-utils:0.5'
Update
As per your comment, you want to resolve the forked version rather than the official one using JitPack. When using JitPack, version must be one of "Release tag, commit hash or -SNAPSHOT" (Building with JitPack). You can try with
com.github.haldertaer:android-maps-utils:master-SNAPSHOT
or
com.github.haldertaer:android-maps-utils:72b39c8
I have just started using Android Studio,
So forgive me if i am unable to explain the situation properly.
But i will try to update details as required.
In my gradle project i use JakeWarton DiskCache with nineoldandroids
Both as jar files added to the app/libs folder.
In addition there also a Library project from this location
https://android-arsenal.com/details/1/122
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.flavienlaurent:datetimepicker:0f5d399995'
}
I use it by adding the repository and dependency as shown above.
When i try to run this project i get following error
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/nineoldandroids/animation/Animator$AnimatorListener.class
I can understand that since my app has a copy of nineoldandroids.jar and the lib-project also needs it at compile time there is some kind of issue.
How can i fix this conflict?
The library com.github.flavienlaurent:datetimepicker:0f5d399995 is using the
nineoldandroids library as a maven dependency.
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
//...
}
Check the original build.gradle file in github.
To solve your issue you have to:
remove the nineoldandroids.jar from your project
add the nineoldandroids library as maven dependency in your project
Use:
dependencies{
//
compile 'com.nineoldandroids:library:2.4.0'
}
I read this page, that learn "importing libraries into android studio". but it's doesn't work for me. i do those step for Material Design Library. in Material Design's build.gradle file have:
https://github.com/navasmdc/MaterialDesignLibrary/blob/master/MaterialDesign/build.gradle
when i click on "Sync Project with Gradle Files" it's gives me two error:
Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.
Error:(3, 0) Plugin with id 'com.jfrog.bintray' not found.
Can any one tell me how to solve those error's?
note: i read this, but don't understand.
If you want to download the Material Design Library and import it without using the gradle method pyus13 mentioned, you need to add the following lines to the MaterialDesign Build.gradle file:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
}
}
To find this file, you can double click on the error you get when syncing that looks like this:
Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.
I also had to add compile project(':MaterialDesign') to the app build.gradle file.
Dont follow the above tutorial, the shown approach is useful when the library has not published as maven or gradle dependency.But as Github page say it is published on maven.
So remove the module or library project completely from your project and use gradle dependency instead.
Just copy this in your app module's build.gradle inside dependencies closure
dependencies {
// YOUR OTHER DEPENDENCIES
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'
}
Sync your project with gradle.
This was kindly answered #pyus13 but I would like to give the complete answer, with the source, github.com/navasmdc/MaterialDesignLibrary#howtouse:
You can use the gradle dependency, you have to add these lines in your
build.gradle file:
repositories {
jcenter()
}
dependencies {
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'
}
The build.gradle you are looking for is in ProjectName\app\src.
Add two dependencies in your Project build.gradle
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
When I build the Amazon (Kindle) flavor of my Android app I run into this Runtime error:
Caused by: java.lang.RuntimeException: Stub!
at com.amazon.device.messaging.ADMMessageReceiver.<init>()
I need the local amazon-device-messaging.jar file to compile my app, however I do not need to include it during runtime as the amazon device will have the necessary classes and methods.
How do I update my Android Studio build.gradle file to do this?
I also ran into this issue. When adding the Amazon Device Messaging jar as a library, Android Studio automatically generated
dependencies {
compile files('libs/amazon-device-messaging-1.0.1.jar')
}
I just needed to switch that to
dependencies {
provided files('libs/amazon-device-messaging-1.0.1.jar')
}
That did the trick for me. I'd up-vote your answer, #Clu, but I don't have a high enough reputation.
To solve this I used the provided type of dependency.
Inside my project modules build.gradle file, right before my dependencies closure I included the following:
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
And then, within my dependencies closure I included the following:
dependencies {
provided files('libs/amazon-device-messaging-1.0.1.jar')
}
This ensured that the .jar was only used for compile time and not runtime. I'm quite new to Android Studio, and this took me a while to figure out; hopefully this will help you make the switch to Android Studio as well.
Add the ADM jar in the Maven local repository.
Command :
mvn install:install-file "-Dfile=amazon-device-messaging-1.0.1.jar" "-DgroupId=com.amazon.device.messaging" "-DartifactId=amazondevicemessaging" "-Dversion=1.0.1" "-Dpackaging=jar"
Include local maven repository as project dependency :
Add “mavenLocal()” in main Gradle build script:
allprojects {
repositories {
mavenCentral()
mavenLocal()
}
Link the Maven artifact in ADM project.
Add below line ADMWrapperLib Gradle script (::).
provided 'com.amazon.device.messaging:amazondevicemessaging:1.0.1'