Access remote gradle dependency - android

This is my first time to make remote repository. But I am facing some problem in accessing it. Following are my gradle files:
root gradle file
// Top-level build file where you can add configuration options
common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.imagelettericon"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.github.akashandroid90:imageletter:1.0'
}
and each time when I sync the code I am getting same error
Failed to resolve: com.github.akashandroid90:imageletter:1.0
I have follow this and this link to make my repo. But now I am not able to access it in gradle file.

Yo have to change your dependency.
compile 'com.github.akashandroid90:imageletter:1.0' is wrong.
Reading the doc in the github repo you should use.
dependencies {
compile 'com.imageletter:ImageLetterIcon:1.0'
}
However you can check the dependency in the jcenter repo.
Reading the pom file in the repo, I have some doubs about the name.
It should be:
compile 'com.github.akashandroid90:image-letter-icon:1.0'
You can use another way to add a dependency with a github project,using the github repo and the jitpack plugin
In this case you have to add this repo tp your build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
and the dependency:
dependencies {
compile 'com.github.User:Repo:Tag'
}
In your case it is
compile 'com.github.akashandroid90:ImageLetterIcon:1.0'
More info here.

Related

Dependency Implementation is not working

So the resource symbol "R" doesn't seem to be working in the MainActivity.java file. I did a clean and rebuild on it but still doesn't work.
Then I get an error message on the console. It says that the implementation file in dependencies is not found. How can I correct this?
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.android.miwok"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
}
From the log you posted there is no reference to the maven google repository where the ConstraintLayout package is stored.
Please make sure you add this repository in the main build.gradle file.
repositories {
google()
}
More info here:
https://developer.android.com/training/constraint-layout/
To use ConstraintLayout in your project, proceed as follows:
Ensure you have the maven.google.com repository declared in your module-level build.gradle file:
repositories {
google()
}
Add the library as a dependency in the same build.gradle file, as shown in the example below. Note that the latest version might be different than what is shown in the example:
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
}
In the toolbar or sync notification, click Sync Project with Gradle Files.
Already described here: Constraint-layout
May be you need to set proxy to your gradle file
gradle.properties:
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=your port
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=your port
check this source
Fixed it:
In the build.gradle (Project) file I added google() to
allprojects {
repositories {
jcenter()
}
}
and made it this:
allprojects {
repositories {
jcenter()
google()
}
}
Is this maven google repository?
I know I fixed it, but I have COMPLETELY no idea why that was the solution. If it is the maven google repository, could someone care to explain?

Facing issue in Latest Support Library v26.0.0-beta1

I am facing weird issue in Latest support library.
I just migrated my project to the latest Support version provided by GOOGLE and as per google guideline
So the problem is can't find the cardView in latest support file. Is anyone facing this problem ?
here is my App Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-O'
buildToolsVersion "26.0.0-rc2"
defaultConfig {
applicationId "com.temp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
lintOptions {
disable 'RestrictedApi'
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$support_libs"
compile "com.android.support:design:$support_libs"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'jp.wasabeef:blurry:2.1.1'
}
// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android O
repositories {
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
and here is the project gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.support_libs = '26.0.0-beta1'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I don't see cardview added to dependencies anywhere in your app gradle file. Try adding:
compile 'com.android.support:cardview-v7:25.3.1'
AppCompat v7 don't contain CardView, you need to make the explicit claim of that lib in your dependencies.
So, add compile 'com.android.support:cardview-v7:$support_libs' to your dependencies.
Add these dependencies in gradle file:
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'

Android: build.gradle error ("Failed to resolve")

So I am trying to implement the infinite scroll in the tabs like this: ViewPager as a circular queue / wrapping. This is github: https://github.com/antonyt/InfiniteViewPager
I am trying to add the dependencies to my build.gradle but I get an error: "Failed to resolve: com.antonyt. infiniteviewpager:library:1.0.0. Do you know how I can solve this? I tried clean project and invalidate cache/restart.
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.example.mariogp18.tanga"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.antonyt.infiniteviewpager:library:1.0.0'
}
This is my other build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my code: https://www.dropbox.com/s/ipe4zz1u3r0lnqt/App.zip?dl=0
This library is not on jcenter - there is also an open ticket for this:
https://github.com/antonyt/InfiniteViewPager/issues/35
you can look here: https://jcenter.bintray.com/com/ - no antonyt there
you might want to use jitpack.io then

Android aar dependencies

I am new to Gradle build system, I have a library project which includes dependencies like Retrofit, okhttp etc.
I compiled my project and created an aar file. I created a dummy project and added my library aar as a dependency.
Now if I don't add Retrofit and okhttp as dependency in my dummy app's build.gradle file, my app crashes with class not found exception.
My Question is : Since the library aar file already includes Retrofit and okhttp as dependency then why do I need to add them explicitly in dummy app's build.gradle file too? Is there a workaround.
Here is my library build.gradle
apply plugin: 'com.android.library'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:cardview-v7:21.+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
}
I was able to resolve this by adding the aar file to a local maven repository. Somehow just adding aar in libs folder and including it as a dependency does not fixes the problem.
If you encounter similar problem just modify your library project build.gradle with these additions
apply plugin: 'maven'
version = "1.0"
group = "com.example.lib"
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.github.dcendents:android-maven-plugin:1.0'
}
}
repositories {
mavenLocal()
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${System.env.HOME}/.m2/repository/")
}
}
}
Run the task in the terminal provided in the Android studio itself as ./gradlew uploadArchives
Then in your app module's build.gradle file, add the library as dependency
compile ('com.example.app:ExampleLibrary:1.0#aar') {
transitive = true;
}

Gradle can not find plugin

I'm trying to integrate TestFairy with my project. I use Android Studio 0.8.2 Beta.
Official site: http://testfairy.com/
There is an example how it works: https://github.com/testfairy/testfairy-gradle-plugin
This is my build.gradle:
repositories {
maven { url 'http://clinker.47deg.com/nexus/content/groups/public';; }
maven { url 'https://www.testfairy.com/maven';; }
}
apply plugin: 'com.android.application'
apply plugin: 'testfairy'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
testfairyConfig {
apiKey "Here is my real api key"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'org.roboguice:roboguice:2.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:support-v4:19.+'
compile 'com.google.android.gms:play-services:4.2.42'
compile 'se.emilsjolander:stickylistheaders:2.3.0'
classpath 'com.testfairy.plugins.gradle:testfairy:1.+'
}
The error I get is:
Error:(6, 0) Plugin with id 'testfairy' not found.
Hot to fix it?
My guess is that you added the TestFairy dependency in the repository closure of you app only. There should be another repositories block for the buildscript, in my project it is in the root gradle file and looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
This lets you define repositories for the build dependencies and app dependencies apart from each other.

Categories

Resources