Question

So I am trying to use actionbarsherlock and viewpagerindicator and for some reason, the viewpagerindicator library does not get imported for some reason. Anyone have any idea?

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.viewpagerindicator:library:2.4.0'
}

dependencies {
    compile project(':libraries:facebook')
}

This import errors out "Cannot resolve symbol viewpageindicator

import com.viewpagerindicator.TabPageIndicator;

These is my "Messages gradle tasks"

Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\android-sdk\build-tools\19.0.1\aapt.exe package -f --no-crunch -I C:\android-sdk\platforms\android-19\android.jar -M C:\myAppName\app\build\manifests\debug\AndroidManifest.xml -S C:\myAppName\app\build\res\all\debug -A C:\myAppName\app\build\assets\debug -m -J C:\myAppName\app\build\source\r\debug -F C:\myAppName\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.myAppName.app --output-text-symbols C:\myAppName\app\build\symbols\debug
Error Code:
    1
Output:
    C:\myAppName\app\build\res\all\debug\values\values.xml:911: error: Error: No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:914: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:934: error: Error: No resource found that matches the given name: attr 'fadeDelay'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:933: error: Error: No resource found that matches the given name: attr 'fadeLength'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:931: error: Error: No resource found that matches the given name: attr 'selectedColor'.


C:\myAppName\app\src\main\res\values\styles.xml
    No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
    Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
    No resource found that matches the given name: attr 'fadeDelay'.
    No resource found that matches the given name: attr 'fadeLength'.
    No resource found that matches the given name: attr 'selectedColor'.
Was it helpful?

Solution

You can't import ViewPagerIndicator via

compile 'com.viewpagerindicator:library:2.4.0'

because that Maven artifact is just a jar of the Java library, but VPI relies on Android resources that aren't in the jar.

Maven artifacts that have AAR packaging do have resources and will work, but VPI isn't packaged that way. It has apklib packaging, but the Android Gradle plugin doesn't support that.

You'll need to download the source and set it up as an android-library module.

You weren't specific about what version of Android Studio you're running, but I'm willing to bet that your problem with the import not working is due to the fact that you're running something earlier than 0.4.3; bugs have been fixed in that area since then.

OTHER TIPS

You can import AAR using this instruction:

In your build.gradle include http://dl.bintray.com/populov/maven as repository priorior to mavenCentral:

repositories {
    maven { url "http://dl.bintray.com/populov/maven" }
    mavenCentral()
}

Use in your dependencies as usual:

dependencies {
    compile 'com.viewpagerindicator:library:2.4.1@aar'
}

Just to add to @serge's answer if you have repositories defined in allprojects tag you'll need to add it there too.

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
    }
}

I use

compile 'com.mcxiaoke.viewpagerindicator:library:2.4.1@aar' 

It's work for me.

And make sure to re sync gradle and rebuild the project

My root build.gradle is:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
        jcenter()

    }
}

and the dependency is: compile 'com.viewpagerindicator:library:2.4.1@aar'

Its works like bomb :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top