Android studio: preDexDebug failed

假装没事ソ 提交于 2019-12-11 09:35:49

问题


I got an error building android project, even a hello world project:

Console output:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Applications/Android Studio.app/sdk/build-tools/19.1.0/dx --dex --output /Users/luyaochen/Documents/and/MyApplication3/app/build/intermediates/pre-dexed/debug/internal_impl-20.0.0-20e875ec0585f022fce03f5b07d31a0222ca3f58.jar /Users/luyaochen/Documents/and/MyApplication3/app/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/libs/internal_impl-20.0.0.jar
  Error Code:
    1


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

please help, I don't know what went wrong


回答1:


I had the same issue, found out that JDK location in project setting pointed to Java 8 directory. Changing it to Java 7 fixed the issue




回答2:


./gradlew assembleDebug worked for me.




回答3:


In my case this problem was caused by a broken build tools version. In my build.gradle file, the build tools pointed to version "21.1.1"

 buildToolsVersion "21.1.1"

That version was actually missing the dx.jar file. It probably happened during a messy upgrade to version 1.2 of Android Studio.

I solved the problem by changing build tools to version 22.0.1 which has the dx.jar file.

I found out when I changed the current directory to my SDK home, and searched for all dx.jar files. Notice that my current build tools version (21.1.1) has one.

glenns-mbp:sdk glennbech$ find . | grep dx.jar
./build-tools/18.0.1/lib/dx.jar
./build-tools/19.0.3/lib/dx.jar
./build-tools/19.1.0/lib/dx.jar
./build-tools/22.0.1/lib/dx.jar



回答4:


Steps to come out from preDexDebug error:

  1. goto file menu
  2. click on settings
  3. apperance and behavior
  4. system settings
  5. Android SDK
  6. select android sdk tools - check whether all tools are installed or not,if not installed then install them.

Come out and rebuild project and click on 'Run' menu. In that click on 'Debug app'. If it shows an error again, follow below steps

  1. click on "gradle scripts" => "build.gradle(Module:app)" => in that file under "default config function" => make both "minsdk version" and "targetsdk version"same.
  2. click on "sync project with gradle files icon" (icon looks like "arrow pointing downwards with green color")
  3. again rebuild and debug_app

I did these steps and i killed that error.



来源:https://stackoverflow.com/questions/25828524/android-studio-predexdebug-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!