Search code examples
androidandroid-studiobuild-error

Android Studio ':app:dexDebug' error when runing a 'hello world' app


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


Solution

  • 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