Can't add ViewPagerIndicator to app with Gradle - android

i am trying to add Jack Whartons ViewPagerIndicator library https://github.com/JakeWharton/ViewPagerIndicator
to my app as i want to use the circle indicator for the viewpager i have. However i am having trouble adding it to my app.
i have followed this tutorial - Using ViewPagerIndicator library with Android Studio and Gradle
However i am getting this error
Error:Artifact 'library.aar (com.viewpagerindicator:library:2.4.1)' not found.
Searched in the following locations:
https://jcenter.bintray.com/com/viewpagerindicator/library/2.4.1/library-2.4.1.aar
if i remove the jCenter() code in my gradle then it works but the other dependencies i have included do not, so i am not sure how to get round having all the dependencies work together.
Here is my top level gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
And here is my module:app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.app.al.app"
minSdkVersion 16
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.0.0'
compile 'com.afollestad:material-dialogs:0.6.2.3'
compile files('libs/volley.jar')
compile 'uk.co.chrisjenx:calligraphy:2.0.2'
compile 'com.viewpagerindicator:library:2.4.1#aar'
}
Thanks for any and all help

You can check the maven repository or jcenter:
http://search.maven.org/#search%7Cga%7C1%7Ccom.viewpagerindicator
https://bintray.com/bintray/jcenter/com.viewpagerindicator%3Alibrary/view#files
There is a library artifact with 2.4.1, but it ISN'T an AAR file.
You have to use an alternative repo
maven { url "http://dl.bintray.com/populov/maven" }, but it is important the order.
Change your script:
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
mavenCentral()
}
}

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?

Not able to use kotlin library

I am trying to use this library for my app but as it is made in kotlin I am facing the problem . I downloaded the module of this library and imported this module in the project but in the initial state i am gettin kotlin plugin not found so i changed the gradel as this
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
resourcePrefix "yal_ms_"
}
buidscript {
ext.kotlin_version = '1.0.1-2'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.1-2'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:26.1.0"
compile "com.android.support:recyclerview-v7:26.1.0"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
jcenter()
}
I am trying to use the kotlin library for the first time and I dont know any thing much about kotlin any advice how to use this library will be helpful .
Try Importing this library by gradle
Add maven { url "https://jitpack.io" } to the repositories of project gradle. So it will be like this
build.gradle(Project)
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and add compile 'com.github.yalantis:multi-selection:v0.1' to dependencies in build.gradle(app)
This may create Manifest Merge Conflicts error while building project to remove that add tools:replace="android:label" under <application> tag in Manifest

Getting an error when using com.google.android.gms:play-services-maps:11.2.0 in my application

I am trying to create a simple Android application. I have the latest version of Android Studio and i think both my gradle build files are correct.
I have placed
implementation 'com.google.android.gms:play-services-maps:11.2.0'
in app gradle dependencies.
Due to this I get the following error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:11.2.0.
I have looked at various links and tried out proposed solutions but none have worked for me.
Below are both my gradle build files.
project build.gradle:
//Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "demo.situm.situmapp"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
//testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
matchingFallbacks = ['release', 'debug']
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.1'
//androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
//apply plugin: 'com.google.gms.google-services'
Hope you can help.
Thanks,
Kabir
try this i found:
Failed to resolve com.google.android.gms play-services-auth:11.2.0
Add maven to your root level build.gradle file
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This maven repo is required starting from 11.2.0.
Or add google() repository to your "build.gradle" file. This gradle method is equivalent to
maven { url "https://maven.google.com" }.
repositories {
jcenter()
google()
}

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 Studio: Repository defined in module not respected

I've got a project in Android Studio and I can't quite seem to figure out this gradle issue. My app structure is as follows:
app (module) relies on crashlib (module), crashlib relies on an AAR from an external repository which I have listed in crashlib's gradle file.
The problem is that when I go to compile the app the default repository (https://jcenter.bintray.com/) is used instead of the one defined in crashlib, so the build fails. If I add the repository definition from crashib to the app module then it builds successfully, but it's not ideal. I can also build crashlib successfully on its own.
Here is the crashlib build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 19
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.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar')
}
Any ideas how to get the repository to be used when building the app?
In your buildscript block you should use somenthing like this:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}

Categories

Resources