0

I hope you guys could give me some help with this problem:

I created a new project in Android Studio 1.0.2 (last stable version at the moment I'm writing this) on windows 7 64 bits. It's a custom 'Hello world' app (new project -> blank activity, etc). When I hit the 'Run app' button, I receive the next error on the Gradle Console:

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava
:app:preDexDebug
:app:dexDebug
trouble writing output: java.security.NoSuchAlgorithmException: MessageDigest SHA-1 implementation not found

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\dbaker\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\dbaker\AndroidStudioProjects\MyApplication\app\build\intermediates\dex\debug --input-list=C:\Users\dbaker\AndroidStudioProjects\MyApplication\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:

    trouble writing output: java.security.NoSuchAlgorithmException: MessageDigest SHA-1 implementation not found


* 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: 3.626 secs

And this is what I have in the project's build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.dbaker.myapplication"
        minSdkVersion 21
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

I already searched for solutions on Stackoverflow and other sites as well, but I tried every possible solution and none of them worked for me (or may be I'm doing something wrong).

Hope you can help me, thanks!

Derek

  • Have you checked this http://stackoverflow.com/questions/17082993/java-security-nosuchalgorithmexception-while-building-a-simple-android-app-using – Piyush Agarwal Jan 19 '15 at 12:51
  • @pyus13 I already did. I created a system environment variable for STUDIO_JDK, which points to my jdk 1.7.0_09 (oracle jdk) – Derek Baker Jan 19 '15 at 13:21

1 Answers1

0

There should be a file $JAVA_JDK/jre/lib/security/java.security in which you have to choose a useful provider. On my machine the paragraph looks like this https://stackoverflow.com/a/16895455/2438200

Community
  • 1
  • 1
QArea
  • 4,955
  • 1
  • 12
  • 22
  • It was that! Android Studio didn't work until I created the STUDIO_JDK variable, but it seems that the program is still using the default JAVA_HOME variable when running the app (not the STUDIO_JDK one). When I change the path of JAVA_HOME to my JDK 7 it worked! The question now would be: How can I keep my JAVA_HOME variable pointing to my ibm JDK but still can run my app? I will check if I can change my project JDK path somewhere in my project settings may be. Thanks! – Derek Baker Aug 31 '20 at 13:25