加入ViewPagerIndicator到Android工作室 [英] Add ViewPagerIndicator to Android Studio

查看:226
本文介绍了加入ViewPagerIndicator到Android工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让杰克沃顿商学院的ViewPagerIndicator与Android工作室工作,但不幸的是它不会起作用。
我下载了的.aar文件,这里并把它列入我的libs文件夹中。
我引用的是这样的:

 编译文件(钢骨混凝土/主/库/ viewpagerindicator_2.4.1.aar)
 

Android的工作室给了我以下错误:

 错误:在APK包装重复文件
 

我不是很熟悉的摇篮,不知道该怎么办时,它给了我这个错误。
能否请你帮我这个吗?

下面是我的完整build.gradle:

 应用插件:com.android.application

安卓{
    compileSdkVersion 19
    buildToolsVersion20.0.0

    defaultConfig {
        的applicationIDde.xxx
        的minSdkVersion 15
        targetSdkVersion 19
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
     推出 {
     runProguard假
     proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
    }
    }
}

依赖{
    编译com.android.support:support-v4:20.0.0
    编译com.github.amlcurran.showcaseview:图书馆:5.0.0
    编译文件(钢骨混凝土/主/库/ PdfViewer.jar)
    编译文件(钢骨混凝土/主/库/ viewpagerindicator_2.4.1.aar)
}
 

解决方案

更新

根据通过的Jürgen'Kashban'Wahlmann 的href="http://stackoverflow.com/a/26138635/1525990">答案给出的

顶级Build.gradle:

  buildscript {
    库{
        行家{URLhttp://dl.bintray.com/populov/maven}
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.12.+
    }
}

allprojects {
    库{
        行家{URLhttp://dl.bintray.com/populov/maven}
        mavenCentral()
    }
}
 

应用程序的build.gradle:

 编译com.viewpagerindicator:库:2.4.1@aar
 

------------

要使用的Andr​​oid ViewPagerIndicator在Android的工作室,你不能从摇篮下载。相反,你必须导入库作为现有项目,以你现在的之一。

按照以下步骤操作:

#1下载源$从GitHub的C $Ç

#2在你的Andr​​oid Studio项目: 文件 - >项目结构 - >添加(+号) - >导入现有项目。进口只是被称为库的文件夹,而不是整个项目(离开导入选项成为Android Studio的建议)。

#3如果您build.gradle规定的compileSdkVersion不与在Android-ViewPagerIndicator项目中指定的匹配,可以改变第二个。同样适用与任何其他财产,如的minSdkVersion,甚至目前的支持库。

#4加入Android的ViewPagerIndicator项目作为依赖于你的build.gradle模块:

 相关性{
    编制项目(':库)
}
 

#5同步项目摇篮文件。

i'm trying to get Jake Wharton's ViewPagerIndicator working with Android Studio but unfortunately it won't work.
I downloaded the .aar file from here and included it in my libs folder.
I referenced it like this:

compile files('src/main/libs/viewpagerindicator_2.4.1.aar')

Android Studio gives me the following error:

Error:duplicate files during packaging of APK

I'm not very familiar with gradle and don't know what to do when it gives me this error.
Can you please help me with this one?

Here's my complete build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "de.xxx"
        minSdkVersion 15
        targetSdkVersion 19
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
     release {
     runProguard false
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
    }
}

dependencies {
    compile 'com.android.support:support-v4:20.0.0'
    compile 'com.github.amlcurran.showcaseview:library:5.0.0'
    compile files('src/main/libs/PdfViewer.jar')
    compile files('src/main/libs/viewpagerindicator_2.4.1.aar')
}

解决方案

UPDATE

Based on the answer given by Jürgen 'Kashban' Wahlmann, it is now possible to add ViewPagerIndicator via gradle:

Top Level Build.gradle:

buildscript {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}

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

App's build.gradle:

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

------------

To use Android-ViewPagerIndicator in Android Studio, you can’t download it from gradle. Instead, you must import the library as an "Existing Project" to your current one.

Follow these steps:

#1 Download source code from GitHub.

#2 In your Android Studio Project: File -> Project Structure -> add (+ symbol) -> Import Existing Project. Import just the folder called "library", not the entire project (leave the import options as Android Studio suggests).

# 3 If the "compileSdkVersion" specified in your build.gradle doesn’t match with the one specified in the Android-ViewPagerIndicator project, change the second one. The same apply with any other property, such as "minSdkVersion" or even the current support library.

# 4 Add Android-ViewPagerIndicator project as a dependency to your build.gradle module:

dependencies {
    compile project(':library')
}

# 5 Sync project with gradle files.

这篇关于加入ViewPagerIndicator到Android工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆