1

I've been trying to move from Eclipse to Android Studio, but as many others i've come across issues with dependencies. I was hoping for someone with more experience with IntelliJ to help me out here.

I've got a working app (in Eclipse) with some simple dependencies, mostly stand-alone jars which were easily ported. In time, I might replace these with Gradle/Maven but for now the Jars will do.

However, I also had NumericPageIndicator as a library project, which in turn Jake Wharton's Android-ViewPagerIndicator which also was a library project.

It's this library, that I can't seem to import.

I've tried adding it as a simple Maven dependency:

  1. First only NumericPageIndicator: compile 'com.github.manuelpeinado.numericpageindicator:library:1.1.1'
  2. And secondly also with Android-ViewPagerIndicator: compile 'com.viewpagerindicator:library:2.4.1'

Both resulting in compile errors indicating that these libraries do not get included (properly).

I'm also not seeing either of these 2 Maven imports under the 'External Libraries' header. I do see them when going to Project structure -> Modules -> Dependencies under the list of jars.

My whole gradle file at the moment is this:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            runProguard false
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('src/main/libs/android-support-v4.jar')
    compile files('src/main/libs/commons-io-1.3.2.jar')
    compile files('src/main/libs/commons-lang3-3.1.jar')
    compile files('src/main/libs/gson-2.2.2.jar')
    compile files('src/main/libs/picasso-1.0.2.jar')
    compile files('src/main/libs/robospice-1.4.1-SNAPSHOT.jar')
    compile files('src/main/libs/robospice-cache-1.4.1-SNAPSHOT.jar')
    compile files('src/main/libs/robospice-ormlite-1.4.1-SNAPSHOT.jar')
    compile files('src/main/libs/robospice-spring-android-1.4.1-SNAPSHOT.jar')
    compile files('src/main/libs/spring-android-core-1.0.1.RELEASE.jar')
    compile files('src/main/libs/spring-android-rest-template-1.0.1.RELEASE.jar')
    compile files('src/main/libs/twitter4j-async-3.0.3.jar')
    compile files('src/main/libs/twitter4j-core-3.0.3.jar')
    compile files('src/main/libs/twitter4j-examples-3.0.3.jar')
    compile files('src/main/libs/twitter4j-media-support-3.0.3.jar')
    compile files('src/main/libs/twitter4j-stream-3.0.3.jar')
    compile files('src/main/libs/ormlite-android-4.45.jar')
    compile files('src/main/libs/ormlite-core-4.45.jar')
    compile 'com.github.manuelpeinado.numericpageindicator:library:1.1.1'
    compile 'com.viewpagerindicator:library:2.4.1'
}
Stefan de Bruijn
  • 6,289
  • 2
  • 23
  • 31
  • Have you double-checked that these libraries are actually available from Maven Central? The artifact IDs look strange. – Peter Niederwieser Dec 08 '13 at 17:15
  • I took the 'links' from their Githubs, but : Jake Wharton's lib: http://search.maven.org/#artifactdetails%7Ccom.viewpagerindicator%7Clibrary%7C2.4.1%7Capklib and the other one: http://search.maven.org/#artifactdetails%7Ccom.github.manuelpeinado.numericpageindicator%7Clibrary%7C1.1.1%7Capklib – Stefan de Bruijn Dec 08 '13 at 17:21
  • Try by invoking Gradle on the command line. This will tell you if a library couldn't be resolved. I'm not sure if Gradle understands the Maven packaging type. Instead, you can try `com.github.manuelpeinado.numericpageindicator:library:1.1.1@apklib`. Note that this won't bring in transitive dependencies. – Peter Niederwieser Dec 08 '13 at 18:24
  • Also have a look at http://stackoverflow.com/questions/15173923/external-android-library-projects-with-gradle, which says that the `apklib` packaging isn't compatible with the new Gradle-based Android build system. – Peter Niederwieser Dec 08 '13 at 18:28

1 Answers1

0

Delete

repositories {
    mavenCentral()
}

You had added it first. No need for the second.

You can do so:

compile 'com.viewpagerindicator:library:+'
Dimentar
  • 603
  • 7
  • 13
  • Both declarations of `mavenCentral` are necessary. The first is for Gradle dependencies, the second for code dependencies. – Peter Niederwieser Dec 08 '13 at 18:20
  • @PeterNiederwieser Strange: I have only one declaration, and all works fine with all my dependencies – Dimentar Dec 08 '13 at 18:23
  • Strange. This likely means that either your Gradle or your code dependencies don't come from Maven Central. – Peter Niederwieser Dec 08 '13 at 18:29
  • @PeterNiederwieser This from where came? : dependencies { compile 'com.android.support:support-v13:+' compile 'com.google.code.gson:gson:+' compile 'org.apache.commons:commons-io:+'} – Dimentar Dec 08 '13 at 18:34
  • Maybe you have configured the repository somewhere else (e.g. parent build script). Without a repository declaration, it won't work. – Peter Niederwieser Dec 08 '13 at 18:54
  • In all my build.gradle files mavenCentral() is declared only in build scripts -> repositories, and all works fine. P.s. I am working with Android Studio(Idea), never with Eclipse – Dimentar Dec 08 '13 at 20:21
  • All I can say is that this has no effect whatsoever on dependencies declared outside the `buildscript` block. – Peter Niederwieser Dec 09 '13 at 09:42