【问题标题】:Execution failed exception执行失败异常
【发布时间】:2017-09-06 23:24:40
【问题描述】:

当我在 android studio 中运行应用程序时,出现此错误

任务执行失败 ':app:transformClassesWithDexForDebug'。

com.android.build.api.transform.TransformException:

java.lang.RuntimeException:

java.lang.RuntimeException: 无法 前索引 'C:\Users\abbasooo.android\build-cache\02f0747de7a8d30b23f383d74adce1e1ad5192a4\output\jars\classes.jar'

'C:\Users\abbasooo\Desktop\tesssst\app\build\intermediates\transforms\dex\debug\folders\1000\10\classes_571d6b5e229e10768234d4a86b076939bc9a4c44'**

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'
    defaultConfig {
        applicationId "com.abbasooo.tesssst"
        minSdkVersion 9
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:design:24.+'
    testCompile 'junit:junit:4.12'
}

这是我的 AndroidManifest.xml强文本

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.abbasooo.tesssst">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

【问题讨论】:

  • 清理和重建项目时会发生什么?

标签: java android android-studio


【解决方案1】:

我遇到了类似的问题,我使用以下方法解决了它:

尝试在

中使用“multiDexEnabled true”

build.gradle 中的 defaultConfig { }

如果不能解决问题,那么使用

android:name="android.support.multidex.MultiDexApplication",在Android Manifest的标签中。

如果问题仍然存在,请使用 org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=5120m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

在 gradle.properties 文件中。

【讨论】:

  • 我忘了一件事。您还在 build.gradle 文件中添加了 compile 'com.android.support:multidex:1.0.1'。
【解决方案2】:

三种方法可以解决这个问题:

  1. 清理并重建项目或尝试一些基本的故障排除。
  2. 重新创建项目。
  3. 重新安装 Android Studio。

【讨论】:

    猜你喜欢
    • 2021-05-01
    • 2014-04-13
    • 1970-01-01
    • 2019-07-14
    • 2019-12-15
    • 2015-06-04
    • 2021-04-01
    • 2022-11-08
    • 2021-06-02
    相关资源
    最近更新 更多