2014-04-05 29 views
46

雖然我在eclipse中導入gradle項目,但它給了我這個錯誤。在eclipse中導入Gradle項目時沒有通過身份驗證

FAILURE: Build failed with an exception. 

* What went wrong: 
A problem occurred configuring root project 'test'. 
> Could not resolve all dependencies for configuration ':classpath'. 
    > Could not resolve de.richsource.gradle.plugins:gwt-gradle-plugin:0.3. 
    Required by: 
     :test:unspecified 
     > Could not GET 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/de/richsource/gradle/plugins/gwt-gradle-plugin/0.3/gwt-gradle-plugin-0.3.pom'. 
     > peer not authenticated 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

我通過代理連接使用互聯網。如果這是問題,那麼在eclipse中指定代理設置。在一般 - >網絡連接,代理設置已經存在

請幫忙。

回答

62

如果你得到任何其他錯誤是這樣的:

Could not GET 'https://some_server.com/some/path/some.pom'. 
    > peer not authenticated 

然後您需要導入證書:

keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit 

它會提示你導入證書,鍵入yes,然後按回車。

然後重新啓動您的eclipse並嘗試構建項目。

+1

做到這一點。它仍然給出同樣的錯誤。進口證書:( – rocker

+0

烏爾構建路徑,是其指向JDK?或JRE? –

+0

肯定的。構建路徑就可以了。有兩個證書導入吧? – rocker

6

導入在上面的回答提出的證書後,編輯您gradle.properties文件,並插入以下行(銘記你的代理服務器設置):

HTTPS:

systemProp.https.proxyHost=www.somehost.org 
systemProp.https.proxyPort=8080 

HTTP:

systemProp.http.proxyHost=www.somehost.org 
systemProp.http.proxyPort=8080 
+0

事實上,他們得到「Peer not authenticated」錯誤意味着他們已經能夠直接訪問repo服務器,或者他們已經配置了代理設置。 – RaGe

+1

這對我有用,我得到了peer not auth錯誤,並注意到我有http代理設置,但沒有https設置,設置https代理與http一樣解決了問題。 –

9

改變你的倉庫在的build.gradle以下

repositories { 
    maven { 
     url "http://repo1.maven.org/maven2" 
    } 
} 
13

答案#2:提供了後兩個負標記

正確的修復將此變爲頂級的build.gradle文件。

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
buildscript { 
    repositories { 
     //jcenter() 
     jcenter { 
      url "http://jcenter.bintray.com/" <=THIS IS THE LINE THAT MAKES THE DIFFERENCE 
     } 
    } 
} 

allprojects { 
    repositories { 
     //jcenter() 
     jcenter { 
      url "http://jcenter.bintray.com/" <=THIS IS THE LINE THAT MAKES THE DIFFERENCE 
     } 
    } 
} 

答案#1(雖然這是不能接受的想保持這個)

如果你看到「同行不是驗證錯誤,這並不一定意味着該應用程序未持有有效證書。也可能意味着連接正在被防火牆,負載平衡器或Web服務器重置。嘗試(重新)以Administator特權啓動應用程序。

在Windows上:

  • 確保您有管理員權限。
  • 右擊應用程序圖標 - >選擇 「以管理員身份運行」

在Linux上:

  • 確保您有root權限。
  • sudo "app execution script name"

+1

作爲管理員/ sudo在計算機上運行如何爲遠程Web服務器或負載平衡器提升特權? – RaGe

+0

它不給予遠程服務器上的權限。您應該閱讀證書進入圖片的HTTPS身份驗證過程。只能使用管理員權限訪問認證存儲位置,因此遠程服務器無法驗證客戶端。我希望現在很清楚。 –

+0

我有同樣的問題。從https://jcenter.bintray.com/導入證書後,可以下載所有.pom文件。但是,一旦腳本開始下載.jar文件,我就再次得到「peer not authenticated」錯誤。但是,如上所述編輯了build.gradle文件後,這個問題就解決了。 – abudaan

1

我嘗試修改存儲庫並導入CER到Java,但都失敗了,那麼我我的JDK版本升級從1.8.0_66到1.8.0_74,構建的gradle成功。

2

從java7升級到java8對我來說確實有竅門。

0

我使用過Android Studio 1.51的Linux(Ubuntu的14.04 LTS),並得到了同樣的錯誤信息:

Error:A problem occurred configuring project ':app'. 
> Could not resolve all dependencies for configuration ':app:_debugCompile'. 
    > Could not resolve com.github.PhilJay:MPAndroidChart:v2.1.6. 
    Required by: 
     dbtraining-dbtrainingandroidapp-517de26197d8:app:unspecified 
     > Could not resolve com.github.PhilJay:MPAndroidChart:v2.1.6. 
     > Could not get resource 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.pom'. 
      > Could not GET 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.pom'. 
       > peer not authenticated 

我試圖移動maven { url "https://jitpack.io" },將其設置爲http來代替HTTPS,激活了「接受非信任證書自動「,手動添加SSL證書...但仍然沒有運氣。

的解決方案是從OpenJDK 7的切換到Oracle JDK 8:

  1. 下載的文件爲JDK從Oracle,我把壓縮包
    (JDK-8u101-Linux的x64.tar.gz ) - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. 提取文件。文件夾名稱爲jdk1.8.0_101
  3. 現在切換到目錄/opt/(鸚鵡螺熱鍵:CTRL + L)並創建一個新文件夾 「Oracle_Java」。也許這需要root權限,所以打開Nautilus 從terimal與sudo nautilus
  4. 將文件夾複製jdk1.8.0_101/opt/Oracle_Javahttps://wiki.ubuntuusers.de/Java/Installation/Oracle_Java/Java_8/#Java-8-JDK按照 說明:不要忘了你的版本替換路徑中的版本佔位符
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" 1 
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" 1 
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" 1 
sudo update-alternatives --install "/usr/bin/jar" "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar" 1 

sudo update-alternatives --set "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" 
sudo update-alternatives --set "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" 
sudo update-alternatives --set "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" 
sudo update-alternatives --set "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar" 
  • 可以在終端與命令java -version如果檢查您的安裝成功。
  • 現在回到android studio並按熱鍵CTRL + SHIFT + ALT + S打開project structure 窗口並轉到SDK Location。在這裏你可以設置路徑JDK,例如 /opt/Oracle_Java/jdk1.8.0_101
  • Change JDK version/path in android studio

    這就是它!:)

    0

    我有這個錯誤,這是因爲VPN代理問題發生。我禁用了我的VPN客戶端,之後一切正常。我用這個命令(在Mac):

    sudo /opt/cisco/anyconnect/bin/acwebsecagent -disablesvc -websecurity

    0

    升級到的gradle這個最新版本修正了這個對我來說。

    1. 更新distributionUrlgradle-wrapper.properties使用最新版本。
    2. 更新gradleVersionbuild.gradle相匹配的版本。
    相關問題