fizzle
fizzle

Reputation: 41

Gradle android application build failed with IntelliJ (java not found issue, but set correctly)

I've problem with build my Android project from IntelliJ. I set up default Android project and try to compile, then:

Error: Gradle: Execution failed for task ':app:preDexDebug'.

(...)

/android-sdk/sdk/build-tools/android-4.4W/dx: line 89: exec: java: not found

I use gradle wrapper from ide. I have java on the PATH, and JAVA_HOME properly. So what is the reason of error?

Upvotes: 1

Views: 976

Answers (2)

fizzle
fizzle

Reputation: 41

I've solved my problem.

I've set my java on the path in .bashrc file. Probably dx runs from shell without read that file, so I set that in '/etc/profile' and it works.

Upvotes: 1

GoGoris
GoGoris

Reputation: 840

Your using android. So you selected the Android API in "Project SDK" in File > Project Structure, and when you click on edit next to the android api, there is a java jdk selected? Your build.gradle file should also contain

apply-plugin: 'android'

and your sourcedir must be set in sourcesets in your build.gradle:

srcDir 'src/java'

more info about getting started with gradle build-files can you find here: http://tools.android.com/tech-docs/new-build-system/user-guide

Upvotes: 0

Related Questions