我正在尝试启动我的第一个Android Studio应用程序,并且在尝试运行或调试时遇到相同的错误。
这是错误:
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\Andreas\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Andreas\Desktop\workspace-androidstudio-mooc\MOOC\app\build\intermediates\dex\debug --input-list=C:\Users\Andreas\Desktop\workspace-androidstudio-mooc\MOOC\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
1
* 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: 1 mins 3.035 secs
建立gradle(应用程式):
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "uk.ac.reading.sis05kol.mooc"
minSdkVersion 8
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'])
}
谁能帮帮我吗?
我已经在整个互联网上搜索了相同的错误,但没有任何解决方案能够解决我的问题。
先感谢您。
最佳答案
您用完了65k方法的限制,请查看此处,了解更多信息https://developer.android.com/tools/building/multidex.html
要使您的应用再次运行,请启用multidex:
在您的app.build文件中:
android {
...
defaultConfig {
...
multiDexEnabled true
}
在您的 list 中:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
或者,您可以覆盖attachBaseContext()方法并调用MultiDex.install(this)以启用multidex。有关更多信息,请参见MultiDexApplication引用文档。
关于android - 任务 ':app:dexDebug'的Android Studio执行失败错误代码:1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30779758/