使用ViewPagerIndicator库与Android Studio和摇篮摇篮、ViewPagerIndicator、Android、Studio

2023-09-12 00:27:05 作者:Chanel(香奈儿)

我试图用杰克沃顿商学院的ViewPagerIndicator库,但我无法得到它与Android的工作室我摇篮的项目工作。

I'm trying to use Jake Wharton's ViewPagerIndicator library, but I'm unable to get it working with my Gradle project in Android Studio.

我将其添加为像这样的依赖关系:

I add it as a dependency like so:

    dependencies {
       // ... other ommitted
       compile 'com.viewpagerindicator:library:2.4.1'
       compile 'com.android.support:support-v4:19.0.1'
       compile 'com.nineoldandroids:library:2.4.0'
       // ...
    }

但该项目似乎并没有认识到任何组件库。我不知道是否有一种依赖性问题,不同的支持-V4版本,或者一些在nineoldandroids ...?

but the project doesn't seem to recognize any components in the library. I'm wondering if there's a dependency issue with different support-v4 versions or something in nineoldandroids...?

推荐答案

一个有点晚了,但在这里:

A bit late to the party, but here:

杰克沃顿商学院还没有公布它的Maven作为AAR。有一组虽然已经通过他们的服务器由它提供的AAR,你可以将它设置像这样在你的build.gradle:

Jake Wharton hasn't released it in maven as an aar. There's a group though that has made an aar of it available through their server, you can set it up like this in your build.gradle:

添加到您的源代码库,你声明你的插件后:

Add this to your source repositories after you declare your plugins:

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

这将输出自己的Maven的回购协议,其中包含了打包的AAR它们放在一起。一旦这样做了,你可以简单地加入这一行到你的依赖,一切都应该工作,一旦你同步你的项目,你的摇篮文件。

This will source their maven repo, which contains a packaged aar that they put together. Once that's done, you can simply add this line to your dependencies and everything should work once you sync your project with your gradle files.

请确保Maven的回购是上面列出的 mavenCentral()项。否则,它会先看看在Maven的中央存储库,发现了错误的包。

Make sure that the Maven Repo is listed above the mavenCentral() entry. Otherwise, it will first look in maven's central repository and find the wrong package.

Android的Studio生成两个 build.gradle 文件的项目,请确保您把这个正确的!

Android Studio generates two build.gradle files for projects, make sure you put this in the right one!

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

我们用它在我们的应用程序,如果你想看到一个工作的例子:

We use it in our app if you'd like to see a working example:

https://github.com/pandanomic/SUREwalk_android/blob/master/surewalk/build.gradle