当前位置: 首页 > 知识库问答 >
问题:

无法通过Ubuntu终端构建Android Studio项目

赏新知
2023-03-14

我的问题似乎类似于通过命令行构建Android Studio应用程序的问题,但它有点不同。我有一个android studio项目,一切都是ok,当使用android studio IDE构建,但我需要通过ubuntu终端构建项目。我键入。/Gradlew build我得到以下错误:

A problem occurred configuring root project 'ContentProvider'.

当键入sudo./gradlew时,会出现以下错误:

正在下载https://services.gradle.org/distributions/gradle-4.1-all.zip

Exception in thread "main" javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916)
    at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1899)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1420)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
    at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
    at org.gradle.wrapper.Download.download(Download.java:44)
    at org.gradle.wrapper.Install$1.call(Install.java:61)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:91)
    at sun.security.validator.Validator.getInstance(Validator.java:179)
    at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:312)
    at sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:171)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:184)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
    ... 14 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
    at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
    at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
    at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:89)
    ... 26 more

即使是项目也是通过IDE构建的,没有任何错误。提前致谢

共有1个答案

笪栋
2023-03-14
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo update-alternatives --config java
sudo update-alternatives --config javac
java -version
wget https://services.gradle.org/distributions/gradle-4.4.1-bin.zip
sudo mkdir /opt/gradle
sudo unzip -d /opt/gradle gradle-4.4.1-bin.zip
export PATH=$PATH:/opt/gradle/gradle-4.4.1/bin
gradle -v
sudo apt install ca-certificates-java
gradle build
android {
  lintOptions {
      abortOnError false
  }
}
 类似资料:
  • 当我试图在mac电脑上以完成cordova项目时,我的终端收到一个错误。它告诉我,它找不到谷歌play服务的版本,如下所示。有人知道什么是潜在的解决方案吗? ➜ AppTest cordova build android android_HOME=/Users/chrono/Downloads/android sdk macosx JAVA_HOME=/Library/JAVA/JavaVirtu

  • 我安装mercurial使用sudo apt-get安装mercurial和它安装正确。但是当我运行任何hg命令时,我都会收到以下错误消息- 中止:在中找不到mercurial库3.3.3.2.2-3.2-3.2.2.2-3.2.2-3.2-3.2-3.2-2.2-3.2-3.3.4-4.4.4.4.4/7/7/7/7/7/7/7/7/4.4/7/7/4.3.2.2.2-3.2-3.2-3.2-3

  • 我第一次安装PhoneGap并试图构建“HelloWorld”项目,但每次都失败了。即使我只创建了一个新项目,也可以在尝试构建之后直接添加Android作为平台。 我使用以下命令:-cordova创建你好com.example.helloHelloWorld-cd Hello/-cordova平台添加android-phonegap本地构建android 错误:http://pastebin.co

  • 我运行的是Mac OSX,我安装了android Studio-它启动正常。 问题1 我用一个空活动开始一个新项目。在最上面的窗户上我收到一条信息 问题2 我在底部窗口中看到以下错误: 错误:CompilesDKVersion android-L需要使用JDK 7 Open SDK Settings进行编译 打开文件 当我尝试在设备上运行项目时,我得到以下错误: 失败[INSTALL_FAILED