Andrei
Andrei

Reputation: 1005

Android studio fails building, dx.bat error

I'm trying to build a new Android project. It is my first time playing around with Android Studio. Please note I am not a Java expert.

I have included Facebook SDK, and since then it is giving me this error:

Gradle: Execution failed for task ':PROJECTNAME:dexDebug'.
> Running C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat failed. See output

I have tried finding out online what could be wrong, but I didn't find anything. Also I have no idea how to see the output, some blog websites recommend to run with "--stacktrace", but I have no idea how to add options to rebuild my project.

I just click on Build -> Rebuild Project

Could anyone please help me ?
Thank you!

Upvotes: 2

Views: 2528

Answers (1)

Andrei
Andrei

Reputation: 1005

Here is my own answer, I think I figured it out:

1) To debug the project (at least with Windows). Open CMD.exe, then navigate to your project folder. Then write: "gradlew build --info"

2) This showed me this message:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/Activ
ityCompatHoneycomb;

Following some information on different blogs, I found one solution, I removed this dependency from my project (but kept it in facebook):

compile files('libs/android-support-v4.jar')

This worked and compiled successfully.

Upvotes: 1

Related Questions