5

Gradle 无法解析org.apache.commons:commons-imaging,但它在所有 3 个提供的存储库中都可用:

  • http://jump-pilot.sourceforge.net/repository

  • https://repo.adobe.com/nexus/content/repositories/public/

  • https://repository.apache.org/content/repositories/snapshots/

这部分日志很有趣,Gradle 只查看jcenter本地文件系统:

https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0 -SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar 文件:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml 文件:/Users/user/Library/Android/sdk /extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom 文件:/Users/user/Library/Android/sdk/extras/android/m2repository/org /apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar 文件:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging /1.0-SNAPSHOT/maven-metadata.xml 文件:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT .pom 文件:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar

控制台日志(请求org.apache.commons:commons-imaging:1.0-SNAPSHOT):

$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find org.apache.commons:commons-imaging:1.0-SNAPSHOT.
     Searched in the following locations:
         https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
         https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
         https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
         file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
         file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
         file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
         file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
         file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
         file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
     Required by:
         ReactNativeProject:app:unspecified > ReactNativeProject:react-native-image-store-ext:unspecified

控制台日志(请求org.apache.commons:commons-imaging:+):

$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find any matches for org.apache.commons:commons-imaging:+ as no versions of org.apache.commons:commons-imaging are available.
     Required by:
         ReactNativeProject:app:unspecified > ReactNativeProject:react-native-image-store-ext:unspecified

build.gradle

buildscript {
  repositories { jcenter() }   
  dependencies { classpath 'com.android.tools.build:gradle:2.1.0' }
}
apply plugin: 'com.android.library'
android {
  compileSdkVersion 23
  buildToolsVersion "23.0.1"
  defaultConfig {
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
  }
  lintOptions { abortOnError false }
}
repositories {
  mavenCentral()
  maven { url "http://jump-pilot.sourceforge.net/repository" }
  maven { url "https://repo.adobe.com/nexus/content/repositories/public/" }
  maven { url "https://repository.apache.org/content/repositories/snapshots/" }
} 
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile "com.facebook.react:react-native:+"
    compile 'org.apache.commons:commons-imaging:+'
}
4

2 回答 2

2

android项目中有2个build.gradle文件:一个在主项目文件夹内,一个在app文件夹内。存储库应在项目文件夹内的 allprojects 块下定义。在这里,我的 build.gradle 示例成功构建了 apache commons 映像。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

allprojects {
    repositories {
        jcenter()
        maven { url "http://jump-pilot.sourceforge.net/repository" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
于 2017-08-15T19:09:02.280 回答
0

显然,还没有 apache commons 映像的官方版本。

我发现的最新非官方版本在这个 repo 上

maven { url "http://wcm.io/maven/repositories/apache-intermediate-release/" }

build.gradle正如 opris 所说,添加这一行。

然后,在你的 gradle app/module 文件中,添加这个

dependencies {
    ...
    implementation 'org.apache.commons:commons-imaging:1.0-R1725432'
    ...
}

我还没有测试过,所以我将不得不在这个和官方版本的sanselan之间进行选择,

compile 'org.apache.sanselan:sanselan:0.97-incubator'

没有更多的支持

于 2019-03-10T20:03:15.703 回答