FAILURE:Gradle 构建失败并出现异常
Posted
技术标签:
【中文标题】FAILURE:Gradle 构建失败并出现异常【英文标题】:FAILURE: Gradle Build failed with an exception 【发布时间】:2015-02-20 16:26:21 【问题描述】:我已将新的android Library Module(dmxmediapicker)
项目包含到我当前工作的Library project(Myapplication)
中,我已将库用于我的Android Module(NormalProject)
。但是在包含库模块后,gradle
无法构建并且它也显示The input line is too long
异常。任何人请提供解决此问题的解决方案。我在互联网上进行了搜索,但找不到更好的解决方案。
例外
:Myapplication:preDexDevDebug
:Myapplication:dexDevDebug
The input line is too long.
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Myapplication:dexDevDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\INO37\AppData\Local\Android\sdk\build-tools\19.1.0\dx.bat --dex --no-optimize --output D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\dex\dev\debug D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\classes\dev\debug D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-787d89f55747f839e6edf29f29d38d35f17b3a30.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\support-annotations-20.0.0-240aab9bab6593b41d1b3b540c6045232da1fa77.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\cwac-sacklist-1.0.1-dda711d827778efe1c760bdb948ba1a39acfd793.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\converter-jackson-1.5.1-f30ef27d5fcffccb406fd4debc4dd598df411298.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\annotations-12.0-b5b365c95aae0dd9d05b7150051dc81ac4a66207.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-6332debc38975f95cd72b9fb79d4ef959550aafc.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\android-viewbadger-6be9349f633a8c52e4e84a7473b884c75df7646f.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\cwac-merge-1.0.4-1690f7eaf3148874821653f2b44eb043d6dfac24.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-9663eb2427df2a79f7656f8997524dff6aba8ed3.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\robospice-retrofit-1.4.12-7add9ad83809cfec85130664e3f0f8d8f4db3812.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\jackson-annotations-2.3.1-12e826dc80ebd316473afbc007d5d62fb9ca931f.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\apktool-lib-1.4.4-3-8ee8794680007892ea0aa71ccf4f62f403b090c0.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-80d40aaa7e9898a9b07a24730ef98c587235ea59.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\slf4j-api-1.7.6-b9d683e8b480a08f5408a9b52ef0e5c371ce1989.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\eventbus-2.2.1-b9680385a60ef0d57864db42aa7b408c98a39042.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-40c97f3059c5dbf257683f47006900cf32413fef.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\bolts-android-1.1.2-441bafc5a672d6d05e9a4e94445d14df854efa44.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\parent-app-template\build\intermediates\pre-dexed\dev\debug\robospice-cache-1.4.12-5cfde6eacf18940c1fb4721fafddd2699e39e6c8.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\parent-app-template\build\intermediates\pre-dexed\dev\debug\vixlet-core-536faacbfbdc9433aee1f435fdb78fcd538268f9.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\parent-app-template\build\intermediates\pre-dexed\dev\debug\library-2.6.0-6a4e906d7bcdb8616d57e8a005349bc659a4824e.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\robospice-1.4.12-003969d6ebfe39f32a146d77d99400c5484dc106.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\retrofit-1.5.1-10a09668d9b0d5fe5ca0227e21727fd008a69d4c.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\internal_impl-20.0.0-6592f598898c5eae47b6699221e16f83ae130dd0.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\library-2.4.0-99f385b1bc28f43ad47d88dcaaee564612041d59.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\commons-io-1.3.2-c3e895cac4d0af50751028ec6b5cf91e13a11944.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\logback-android-classic-1.1.1-2-e37f9f12967b461668ea7a08aa31566dc647e9cb.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\universal-image-loader-1.9.2-30f8c46db3505acf9c16140d5124dce613db573a.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\jackson-core-2.3.1-569c0b6fff725c0772a2544b76c505956a040cb3.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\logback-android-core-1.1.1-2-ba8bc87e327fe59477b1a30abe6b447e438a32c5.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\okhttp-1.5.4-41055e1ec4b4b9e132ba9b71d7cc04e5a8a5553d.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\twitter4j-core-4.0.2-84defff66a9193544b9ef0f2c15565686a93cf7b.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-0cf819e9a2eb35706dd00dfff8f168e26bb6a9e5.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\commons-lang3-3.3.2-c4491073f0be9d854ecd8b34d316f7f2bc02ca21.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-ce1a88d8493673e442b95c84f6ac34b0b16fd5e4.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-499ae4fd3a32c9bb92892715a01ef3a35567e56c.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-2b5d899cfe71f40eb1264e9826473d56e636ace6.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\jackson-databind-2.3.1-ad7662486febdd462bc1d048504a9658311ead09.jar
Error Code:
255
Output:
The input line is too long.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
dmxmediapicker 的 biuld.gradle
apply plugin: 'android-library'
android
compileSdkVersion 20
buildToolsVersion '19.1.0'
defaultConfig
minSdkVersion 12
targetSdkVersion 20
versionCode 1
versionName "1.0"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions
abortOnError false
dependencies
compile 'com.android.support:appcompat-v7:20.0.0'
用于 MyApplication 的 biuld.gradle
buildscript
repositories
mavenCentral()
maven
url 'https://oss.sonatype.org/content/repositories/snapshots/'
dependencies
classpath 'com.android.tools.build:gradle:1.0.0'
apply plugin: 'com.android.library'
android
compileSdkVersion 20
buildToolsVersion "19.1.0"
compileOptions
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
defaultConfig
minSdkVersion 12
packagingOptions
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
dependencies
compile project(":dmxmediapicker")
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
用于 NormalProject 的 biuld.gradle
buildscript
repositories
mavenCentral()
maven
url 'https://oss.sonatype.org/content/repositories/snapshots/'
dependencies
classpath 'com.android.tools.build:gradle:1.0.0'
apply plugin: 'com.android.application'
android
compileSdkVersion 20
buildToolsVersion "19.1.0"
packagingOptions
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
productFlavors
dev
staging
production
lintOptions
abortOnError false
defaultConfig
minSdkVersion 12
targetSdkVersion 20
compileOptions
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
buildTypes
debug
debuggable true
signingConfig signingConfigs.test
release
debuggable false
signingConfig signingConfigs.release
dependencies
compile project(':MyApplication')
【问题讨论】:
你试过 buildToolsVersion "21.1.2" 我认为目录名称很大,Windows 不支持那么长的命令。尝试将您的 android 项目移动到 D: 驱动器而不是 D: 上的任何文件夹中。可能有用! @ligi 我试过了,现在效果很好。在这里发布你的答案我会接受的。 【参考方案1】:根据ligi's
评论
我已经设置了buildToolsVersion As 21.1.1
现在构建问题已经解决了。
【讨论】:
【参考方案2】:这将解决您的问题
在 Android Studio 中,转到 Tools->SDK manager 并查看您的 android 版本 是否已下载(对于您选择作为虚拟设备的任何模拟器) . 如果没有下载它并再次播放模拟器。
现在应该可以了!!
【讨论】:
以上是关于FAILURE:Gradle 构建失败并出现异常的主要内容,如果未能解决你的问题,请参考以下文章
FAILURE:构建失败并出现异常。 * 其中:构建文件 'C:\Users\mayev\dev\remplazo\Chronos\android\app\build.gradle' 行:81