You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS下启动Android Studio报错:SHA-1不可用的InternalError

Fixing "SHA-1 not available" Error When Launching Android Studio on CentOS

Hey, I’ve run into this exact issue before on CentOS—let’s get you up and running with Android Studio again. That error pops up because your Java environment doesn’t have access to the SHA-1 algorithm, usually due to restricted crypto policies in OpenJDK. Here are the actionable steps to fix it:

Step 1: Check Your Java Version

First, confirm which JDK you’re using. Run this in your terminal:

java -version

Chances are it’s an OpenJDK build—CentOS defaults to this, and its out-of-the-box crypto policies block some algorithms like SHA-1 in specific contexts.

Step 2: Install Unlimited JCE Policy (OpenJDK)

The simplest fix is to install the unlimited strength crypto policy package for your OpenJDK version. For Java 8 (the most common for older Android Studio releases), run:

sudo yum install java-1.8.0-openjdk-unlimited-jce-policy

If you’re using Java 11 or newer, adjust the package name to match your version (e.g., java-11-openjdk-unlimited-jce-policy).

Step 3: Manually Replace Crypto Policy Files (If Yum Fails)

If the package isn’t available in your repo, you can manually update the policy files:

  1. Grab the appropriate unlimited strength JCE files for your Java version.
  2. Navigate to your JDK’s security directory (replace <version> with your actual OpenJDK version):
    cd /usr/lib/jvm/java-1.8.0-openjdk-<version>/jre/lib/security/
    
  3. Backup the original files first to be safe:
    sudo cp local_policy.jar local_policy.jar.bak
    sudo cp US_export_policy.jar US_export_policy.jar.bak
    
  4. Copy the downloaded unlimited policy files into this directory:
    sudo cp /path/to/downloaded/local_policy.jar .
    sudo cp /path/to/downloaded/US_export_policy.jar .
    

Step 4: Switch to Oracle JDK (As a Last Resort)

If OpenJDK still gives you trouble, switching to Oracle JDK often resolves crypto-related quirks. Here’s how:

  1. Download the Oracle JDK (match the version Android Studio recommends) from Oracle’s official site.
  2. Extract it to a directory like /opt/java/jdk-<version>/.
  3. Update your environment variables temporarily to test:
    export JAVA_HOME=/opt/java/jdk-<version>
    export PATH=$JAVA_HOME/bin:$PATH
    
  4. Try launching Android Studio again. If it works, add these variables to your ~/.bashrc or ~/.profile to make the change permanent.

Step 5: Verify SHA-1 is Available

To confirm the fix worked, create a quick test program:

import java.security.MessageDigest;

public class TestSHA1 {
    public static void main(String[] args) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            System.out.println("SHA-1 is now available!");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Compile and run it with:

javac TestSHA1.java && java TestSHA1

If you see the success message, you’re all set—launch Android Studio and it should work without a hitch.

内容的提问来源于stack exchange,提问作者shadow_wxh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:35:29