Programing

Android Studio 및 Gradle과 함께 ViewPagerIndicator 라이브러리 사용

lottogame 2020. 7. 20. 21:07
반응형

Android Studio 및 Gradle과 함께 ViewPagerIndicator 라이브러리 사용


Jake Wharton의 ViewPagerIndicator 라이브러리 를 사용하려고하는데 Android Studio에서 Gradle 프로젝트와 작동하지 않습니다.

다음과 같이 종속성으로 추가합니다.

    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'
       // ...
    }

그러나 프로젝트가 라이브러리의 구성 요소를 인식하지 못하는 것 같습니다. 다른 support-v4 버전 또는 nineoldandroids의 항목에 종속성 문제가 있는지 궁금합니다.


방금 maven central 내부에 버전을 푸시 했으므로 해당 종속성을 추가하기 만하면됩니다.

compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'

그리고 다음과 같이 maven central을 선언하십시오.

repositories {
    mavenCentral()
}

그것이 도움이되기를 바랍니다 ...


파티에 조금 늦었지만 여기 :

제이크 와튼 (Jake Wharton)은 그것을 aven으로 maven에서 공개하지 않았습니다. 서버를 통해 사용할 수있는 그룹이 있지만 build.gradle에서 다음과 같이 설정할 수 있습니다.

플러그인을 선언 한 후 소스 리포지토리에 추가하십시오.

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

이것은 그들이 모은 패키지 된 aar를 포함하는 maven repo를 제공 할 것입니다. 완료되면 종속성 에이 줄을 추가하면 프로젝트를 gradle 파일과 동기화하면 모든 것이 작동합니다.

Maven Repo가 항목 위에 나열되어 있는지 확인하십시오 mavenCentral(). 그렇지 않으면 먼저 maven의 중앙 저장소를보고 잘못된 패키지를 찾습니다.

Android Studio는 build.gradle프로젝트를 위해 두 개의 파일을 생성 하므로 올바른 파일에 넣으십시오.

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

실제 예제를 보려면 앱에서 사용합니다.

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


Android Studio 0.8.2에서 gradle 0.10 이상을 사용하고 있으며 허용되는 답변이 작동하지 않습니다. 다음은 프로젝트에서 ABS를 작동시키기 위해 수행해야 할 약간의 변경 사항입니다.

build.gradle프로젝트의 최상위 파일에서 다음 allprojects과 같이 구성에 maven 저장소를 추가하십시오 .

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

그리고 모듈 build.gradle파일에서 @aar: 없이 의존성을 추가하십시오 :

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

Jitpack.io는 것이다 이 상황에.

먼저 다음 저장소를 추가하십시오.

repositories {
    // ...
    maven { url "https://jitpack.io" }
}

그런 다음 GitHub 저장소를 가리키는 종속성을 추가하십시오.

dependencies {
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
}

앱 모듈의 build.gradle 파일에서 다음과 같이 종속성에 추가하십시오.

dependencies {
   compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
   ...
}

나는 이것을 따라 트릭을했다. 라이브러리를 가져올 필요가 없습니다. 두 단계와 빙고만으로도 완벽하게 작동합니다.

build.gradle (Project : ...)에서 :

allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }

build.gradle (모듈 : 앱)에서 :

dependencies {
            compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    }

답변이있는 프로젝트를 가져올 수 없었습니다. Android Studio 0.8.6 및 gradle 1.12를 사용하고 있습니다.

내가 생각해 낸 유일한 해결책은 다음에서 .aar 라이브러리를 다운로드하는 것입니다.

http://dl.bintray.com/populov/maven/com/viewpagerindicator/library/2.4.1/

그런 다음 라이브러리를 다음과 같이 gradle로 가져옵니다.

 repositories {
      flatDir {
        dirs 'libs'}
   }

 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile(name:'library-2.4.1', ext:'aar') 
  }

도움이 되었기를 바랍니다!


Studio 0.8.6 및 Gradle 1.12를 사용하고 있습니다.

내 프로젝트의 차이점은 gradle이 support-v4lib를 두 번 갖는 것에 대해 불평하게하는 호환성 라이브러리를 사용한다는 것 입니다.

그래서 이미 포함 된 것을 제외해야 support-v4했습니다.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:19.0.1'
    compile 'com.android.support:appcompat-v7:19.0.1'    
    compile ('com.viewpagerindicator:library:2.4.1') {
        exclude module: 'support-v4'
    }
}

그런 다음 AndroidManifest.xml파일을 두 번 갖는 것에 대해 불평 했습니다.

그래서 나는 또한 exclude 'AndroidManifest.xml'다음 android과 같이 섹션에 추가 했습니다 :

android {
    packagingOptions {
        exclude 'AndroidManifest.xml'
    }

그런 다음 효과가있었습니다.


please make sure that support:support-v4 is same in all the libs and yours application, sometime it causes problem so use same support:support-v4 across libs and your app project.


The post marked as answer didn't work for me...Gradle complained about "Connection refused".

Considering that it looks like it's stable after all this time, I just download the aar file from https://bintray.com/populov/maven/com.viewpagerindicator:library, copied into my libs folder, and referenced it like so:

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

This is what worked for me:

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

i.e, do not use the repo URL.

then use:

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

Add it in your build.gradle at the end of repositories:
Ste 1
 repositories {
        // ...
        maven { url "https://jitpack.io" }
    }
Step 2. Add the dependency in the form

    dependencies {
            compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
    }

Also try to put maven repository before others.

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

        // 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 build with dependencies:

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId ""
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

For the sake of variety here is an answer that doesn't use maven:

  1. Download zip/tgz from ViewPagerIndicator

  2. In the project window, select project navigation.

  3. Go to project > New > Module.

  4. Import Gradle Project

  5. Browse to and select the unzipped library folder. Name the module whatever you want to. I named it viewPagerIndicator

  6. Keep clicking next until you reach the last window where Finish is clickable. If you get the Android Support Library is not installed message, don't worry. Just go ahead and click Finish.

  7. Wait for gradle build and project compilation to finish. Once completed, add this to dependencies { .. } in build.gradle (Module:app):

     compile project(':viewPagerIndicator')
    

The library is now available for your use.


Please check this first

Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:

if these checks are ok do mentioned below.

No need to include support-v4 as dependency of your module because ViewPagerIndicator library already having support-v4 as its dependency. So you can try to remove that and do sync with gradle using tiny lovely gradle button available in toolbar -

enter image description here

Update your question if you are getting any error in syncing.

UPDATED :

I am not sure but It might be a problem I did not find any ViewPagerIndicator Library based on gradle. JackWarton has moved actionbarsherlock in gradle but ViewPagerIndicator still using maven.


You can just include the ViewPagerIndicator library directly within your application as described here

It enables you to import the ViewPagerIndicator library as an “Existing Project” to your current project.


For me also any of the above solution didn't worked. But this worked for me.

  1. Just include the required librabry from here Viewpagerindicator Library

  2. Include this in your app module's build.gradle (you won't have repository there just include it above dependencies.

repositories {
    flatDir{
        dirs 'libs'
    }
}

  1. add this into your dependencies.

compile (name:'library-2.4.1',ext:'aar')


To sum up: you can search "ViewPagerIndicator" in http://mvnrepository.com/, you will find out the original com.viewpagerindicator doesn't have the red marker "Android Packages", so you cannot use it with Gradle. You can find another one with the red marker, make sure it has the same version as the original one. (i.e. some one create an android package based on the original one)


It has an issue of newer gradle. Just change dependency like below.

implementation 'com.inkapplications.viewpageindicator:library:2.4.3'

참고URL : https://stackoverflow.com/questions/21130003/using-viewpagerindicator-library-with-android-studio-and-gradle

반응형