gpt4 book ai didi

android - Ubuntu 16/Cordova 6.4/Android : Could not resolve com. android.tools.build:gradle

转载 作者:太空宇宙 更新时间:2023-11-03 22:28:56 28 4
gpt4 key购买 nike

我正在尝试在 Ubuntu 16 操作系统中将 Cordova 6.4 与 Android Studio 结合使用。

我已经正确安装了Android Studio并下载了SDK。

并且 npm 和 cordova 也已安装。

<小时/>

我尝试创建一个项目:

cordova create myapp
cd myapp
cordova platform add android

这会产生以下错误:

Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: io.cordova.hellocordova
Name: HelloCordova
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android@6.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Fetching plugin "cordova-plugin-whitelist@1" via npm
Installing "cordova-plugin-whitelist" for android
ANDROID_HOME=/home/alfred/Android/Sdk/
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.0.
Required by:
:android:unspecified
> Could not resolve com.android.tools.build:gradle:2.2.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.tools.build:gradle:2.2.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* 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: 4.847 secs
Failed to install 'cordova-plugin-whitelist':Error: /home/alfred/app/myapp/platforms/android/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/home/alfred/app/myapp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Error: /home/alfred/app/myapp/platforms/android/gradlew: Command failed with exit code 1

如果我在那之后运行cordova run android,它仍然告诉 block 无法解析com.android.tools.build:gradle:2.2.0.错误。

在 Windows 下似乎没有发生同样的事情。

我在网上搜索过,但没有运气。有人知道怎么做吗?

最佳答案

下面的文章讲述如何将特定站点的ssl证书导入到java环境中。

https://github.com/meteor/meteor/issues/6362#issuecomment-262684912

<小时/>

第 1 步:下载证书

下载此文件。

或者在 Mozilla Firefox 上也是如此:

转到https://repo1.maven.org

  • 点击地址栏左侧的绿色挂锁。
  • 点击“详细信息”。
  • 点击“查看证书”。
  • 点击“详细信息”。
  • 点击“导出”。
  • 将文件导出到“X.509 证书 (PEM) (*.crt; *.pem)”

第 2 步:将证书添加到默认 java keystore

sudo keytool -import -alias MavenRepo -keystore $JAVA_HOME/jre/lib/security/cacerts -file /PATH/TO/YOUR/EXPORTED/FILE.crt

您的 $JAVA_HOME 变量通常在您的 .bashrc 文件中声明,因此您可以使用此命令,只需替换 /PATH/TO/YOUR/EXPORTED/FILE 参数。

PS : The default password of java keystore is : changeit

<小时/>

它使程序向前推进了一点,但仍然没有解决。

最后我通过重装操作系统解决了这个问题。

似乎与ubuntu或linux本身无关,重装操作系统后,codova和android studio在ubuntu中运行良好。

关于android - Ubuntu 16/Cordova 6.4/Android : Could not resolve com. android.tools.build:gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40738560/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com