我正在使用带有 Linux(Ubuntu 14.04 LTS)的 android studio 1.51 并收到相同的错误消息:
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:
- 从 Oracle 下载了 JDK 的文件,我使用了 tarball
(jdk-8u101-linux-x64.tar.gz) - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151 .html
- 提取文件。文件夹名称是
jdk1.8.0_101
- 现在切换到目录
/opt/
(nautilus 热键:CTRL+L)并创建一个新文件夹“Oracle_Java”。也许这需要root访问权限,所以从终端打开nautilussudo nautilus
- 将文件夹复制
jdk1.8.0_101
到/opt/Oracle_Java
按照 https://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 并
project structure
通过按热键 CTRL+SHIFT+ALT+S 打开窗口并转到SDK
Location
. 这里可以设置JDK的路径,例如
/opt/Oracle_Java/jdk1.8.0_101
而已!:)