Creación de una compilación de Gradle para Android que utiliza ViewPagerIndicator

Cuando ejecuto gradle AssembleDebug obtengo un error diciendo que support-v4 ya está agregado. No puedo entender por qué se agrega dos veces. A continuación se muestra la estructura completa del proyecto y el registro de errores.

Mi estructura del directorio es como sigue (los directorios adicionales quitados para la claridad).

 ├── settings.gradle ├── project │  ├── AndroidManifest.xml │  ├── build.gradle │  ├── res │  └── src └── vpi ├── AndroidManifest.xml ├── build.gradle ├── res └── src 

Settings.gradle contiene

 include 'project' include 'vpi' 

Project / build.gradle contiene

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') } repositories { mavenCentral() } dependencies { compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' compile 'org.jsoup:jsoup:1.7.2' compile project(':vpi') } android { compileSdkVersion 18 buildToolsVersion "18.1" sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/<type> // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src/<type>/... which would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be accompanied // by a similar customization. debug.setRoot('build-types/debug') release.setRoot('build-types/release') } } 

Vpi / build.gradle contiene

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android-library' repositories { mavenCentral() } dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile 'com.android.support:support-v4:18.0.+' } android { compileSdkVersion 18 buildToolsVersion "18.1" sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } } } 

Cuando ejecuto el comando gradle AssembleDebug obtengo este resultado.

 :project:preBuild UP-TO-DATE :project:preDebugBuild UP-TO-DATE :project:preReleaseBuild UP-TO-DATE :vpi:compileLint :vpi:copyReleaseLint UP-TO-DATE :vpi:mergeReleaseProguardFiles UP-TO-DATE :vpi:packageReleaseAidl UP-TO-DATE :vpi:preBuild UP-TO-DATE :vpi:preReleaseBuild UP-TO-DATE :vpi:prepareReleaseDependencies :vpi:compileReleaseAidl UP-TO-DATE :vpi:compileReleaseRenderscript UP-TO-DATE :vpi:generateReleaseBuildConfig UP-TO-DATE :vpi:mergeReleaseAssets UP-TO-DATE :vpi:mergeReleaseResources UP-TO-DATE :vpi:processReleaseManifest UP-TO-DATE :vpi:processReleaseResources UP-TO-DATE :vpi:generateReleaseSources UP-TO-DATE :vpi:compileRelease Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :vpi:processReleaseJavaRes UP-TO-DATE :vpi:packageReleaseJar UP-TO-DATE :vpi:packageReleaseLocalJar UP-TO-DATE :vpi:packageReleaseRenderscript UP-TO-DATE :vpi:packageReleaseResources UP-TO-DATE :vpi:bundleRelease UP-TO-DATE :project:prepareAndroidAppVpiUnspecifiedLibrary UP-TO-DATE :project:prepareComActionbarsherlockActionbarsherlock440Library UP-TO-DATE :project:prepareDebugDependencies :project:compileDebugAidl UP-TO-DATE :project:compileDebugRenderscript UP-TO-DATE :project:generateDebugBuildConfig UP-TO-DATE :project:mergeDebugAssets UP-TO-DATE :project:mergeDebugResources UP-TO-DATE :project:processDebugManifest UP-TO-DATE :project:processDebugResources UP-TO-DATE :project:generateDebugSources UP-TO-DATE :project:compileDebug UP-TO-DATE :project:dexDebug UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl; at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123) at com.android.dx.dex.file.DexFile.add(DexFile.java:163) at com.android.dx.command.dexer.Main.processClass(Main.java:490) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459) at com.android.dx.command.dexer.Main.access$400(Main.java:67) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109) at com.android.dx.command.dexer.Main.processOne(Main.java:422) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333) at com.android.dx.command.dexer.Main.run(Main.java:209) at com.android.dx.command.dexer.Main.main(Main.java:174) at com.android.dx.command.Main.main(Main.java:91) 1 error; aborting :project:dexDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':project:dexDebug'. > Failed to run command: /Applications/Android Studio.app/sdk/build-tools/18.1.0/dx --dex --output /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/build/libs/project-debug.dex /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/build/classes/debug /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/build/dependency-cache/debug /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/libs/GoogleAdMobAdsSdk-6.4.1.jar /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/build/exploded-bundles/AndroidAppVpiUnspecified.aar/libs/android-support-v4.jar /Users/yasith/.gradle/caches/artifacts-26/filestore/org.jsoup/jsoup/1.7.2/jar/d7e275ba05aa380ca254f72d0c0ffebaedc3adcf/jsoup-1.7.2.jar /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/libs/libGoogleAnalyticsV2.jar /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/build/exploded-bundles/AndroidAppVpiUnspecified.aar/classes.jar /Users/yasith/Projects/Mississauga-Busses/AndroidApp/project/build/exploded-bundles/ComActionbarsherlockActionbarsherlock440.aar/classes.jar /Applications/Android Studio.app/sdk/extras/android/m2repository/com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar Error Code: 1 Output: UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl; at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123) at com.android.dx.dex.file.DexFile.add(DexFile.java:163) at com.android.dx.command.dexer.Main.processClass(Main.java:490) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459) at com.android.dx.command.dexer.Main.access$400(Main.java:67) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109) at com.android.dx.command.dexer.Main.processOne(Main.java:422) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333) at com.android.dx.command.dexer.Main.run(Main.java:209) at com.android.dx.command.dexer.Main.main(Main.java:174) at com.android.dx.command.Main.main(Main.java:91) 1 error; aborting * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 25.296 secs 

One Solution collect form web for “Creación de una compilación de Gradle para Android que utiliza ViewPagerIndicator”

Cambiado mi archivo de proyecto / build.gradle para que parezca esto. (Eliminado el bit compile 'com.android.support:support-v4:18.0.0' ).

 dependencies { compile project(':vpi') compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' compile 'org.jsoup:jsoup:1.7.2' compile fileTree(dir: 'libs', include: '*.jar') } 

Esto parece hacer gradle DebugAssemble trabajo. Hice correr gradle clean DebugAssemble demasiado, no estoy seguro de si eso tenía algo que ver con este trabajo.

También tuvo que agregar un archivo local.properties a la raíz del proyecto que contenía.

 sdk.dir=/Applications/Android Studio.app/sdk 

Después de hacer esto, la importación del archivo settings.gradle de Android Studio funcionó.

  • No se pudo encontrar el estilo vpiCirclePageIndicatorStyle
  • Pestañas de ViewPagerIndicator: Iconos sobre el texto
  • Cómo agregar una vista personalizada en ViewPager para un tutorial
  • Tirar para actualizar y loadmore listview como facebook
  • Android ViewPager con puntos inferiores
  • Utilizar varios diseños en ViewPageIndicator
  • Java.lang.IllegalStateException: ViewPager no se ha consolidado (usando el indicador JakeWharton ViewPager)
  • Resaltar o subrayar seleccionado TabPageIndicator
  • Accidente después de agregar el elemento al menú de opciones de la barra de acción de Fragmento seguido de cambio de orientación
  • Cómo implementar en el icono de escuchar el clic en IconPageIndicator
  • Deshabilitar animación suave al hacer clic en las pestañas con ViewPagerIndicator
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.