android - 任务 ':app:dexDebug'的Android Studio执行失败错误代码:1

标签 android debugging android-studio gradle build.gradle

我正在尝试启动我的第一个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/

相关文章:

javascript - 如何将数据从 Node 发送到另一台服务器

java - 不幸的是 MyApp 已停止。我该如何解决这个问题?

android - 如何在构建 Android App Bundle 时指定环境变量

android - 在平板电脑的 Android 应用程序中获取外部存储路径

android - Parse.com, Parse SDK 下载 SDK 中没有 Parse-1.10.3.jar 文件

android - launchMode singleTask 中的 Activity 在通过 TaskStackBuilder 启动时被销毁

android - AAPT 错误 : Invalid BCP 47 tag in directory name b+sr+latn_values

visual-studio-2010 - 在哪里可以找到 natvis 模式定义(用于创建 VC++ 调试器可视化工具)?

android - 导航到另一个 Fragment 时,Fragment 中的 RecyclerView 崩溃

mysql - Codeigniter 中的查询时间比 Phpmyadmin 中的查询时间长