简体   繁体   English

在Android Studio中查看传呼机指示器

[英]View pager indicator in android studio

I want to use view pager indicator library in android studio. 我想在android studio中使用view pager indicator库。 As it is available for the maven and not for the gradle project yet so I am adding library folder in android studio and including it in app build.gradle file. 由于它适用于Maven而不适用于gradle项目,因此我将库文件夹添加到android studio中,并将其包含在应用程序build.gradle文件中。 Problem arises, when I compiled the project so it wont compile as both the app and library gradle files are using android-support-v4.jar files. 问题出现了,当我编译该项目时,由于应用程序和库gradle文件都使用android-support-v4.jar文件,因此不会进行编译。 I need to know how can I use the library in android studio. 我需要知道如何在android studio中使用该库。

settings.gradle settings.gradle

   include ':app'
   include ':library'
   include ':sample'

app/build.gradle 应用程序/的build.gradle

apply plugin: 'android'
android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"
    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':library')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
}

library.gradle library.gradle

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

apply plugin: 'android-library'

android {
    sourceSets {
        main {
            java.srcDirs = ['src']
            manifest.srcFile 'AndroidManifest.xml'
            res.srcDirs = ['res']
        }
    }

    compileSdkVersion 19
    buildToolsVersion '19.0.3'
}

dependencies {
    compile files('libs/android-support-v4.jar')
  // compile 'com.android.support:support-v4:19.+'
   // compile fileTree(dir: 'libs', include: ['*.jar'])
}

Don't include the support library by adding a direct dependency to its jar file as you have in your library's build.gradle file. 不要像在库的build.gradle文件中那样向其jar文件添加直接依赖项来包括支持库。 If you include it everywhere via the Maven-coordinate-style include, like your commented out line, the build system won't have trouble with duplicates: 如果您通过Maven坐标样式的include将其包含在任何地方,例如注释行,则构建系统不会遇到重复项的麻烦:

dependencies {
    compile 'com.android.support:support-v4:19.+'
}
  1. Select "Projects" module in android studio. 在android studio中选择“项目”模块。
  2. download and unzip the ViewPagerIndicator-Library. 下载并解压缩ViewPagerIndicator-Library。
  3. Create the libs folder under root folder and copy paste the library into that folder. 在根文件夹下创建libs文件夹,然后将库复制粘贴到该文件夹​​中。
  4. go to settings.gradle and add this line: include ':libs:ViewPagerIndicator-Library' 转到settings.gradle并添加以下行: include ':libs:ViewPagerIndicator-Library'
  5. add the compile project(':libs:ViewPagerIndicator-Library') in app's build.gradle model 在应用程序的build.gradle模型中添加compile project(':libs:ViewPagerIndicator-Library')
  6. Restart the studio and Have Fun ... 重新启动工作室并玩得开心...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM