:app:transformClassesWithMultidexlistForDebug 失败
:app:transformClassesWithMultidexlistForDebug FAILED
我试过以下链接
http://developer.android.com/intl/es/tools/building/multidex.html
Android Studio TransformException : Error:Execution failed for task ':app:transformClassesWithDexForDebug'
我的gradle构建文件如下。
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "appId"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile files('libs/rt.jar')
compile 'com.android.support:multidex:1.0.0'
}
我的清单如下。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="packageName">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的activity文件如下。
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
经过这一切,我仍然得到以下错误。
Error:Execution failed for task
':app:transformClassesWithMultidexlistForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_72\bin\java.exe'' finished with non-zero exit value 1
回答
我必须在应用级别执行以下操作
- 删除 rt.jar 作为库
- 从 build.gradle
中删除 compile files('libs/rt.jar')
- 清理并构建项目。
感谢 George Mulligan 指出。
我不确定 Windows OS 和直线 JAVA 是否相同。我在 cordova run android
中遇到了同样的问题,它总是在 Mac 中失败。所以我将以下内容添加到我的 build.gradle 文件中并且构建通过了,并且我能够在模拟器上进行测试。在 android 部分下添加编译信息,在默认配置下添加 multidex
android {
compileSdkVersion 23
buildToolsVersion "23"
}
defaultConfig {
multiDexEnabled true
}
请注意构建版本仅为 23 而不是 23.0.1
我知道通过了。但我有同样的问题。
消息是这样的:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [D:...app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:....\support-core-ui-27.1.1.aar\eadf2be3981e05166424b72b4128200e\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager.class]))
我搜索了很多但没有找到。
我通过在 gradle:
中添加以下行来解决它
implementation 'com.android.support:support-v4:27.0.2'
我找到了快速修复方法。但可能有更好的解决方案。
changing minSdkVersion means it will not gonna work for below the sdk version
在您的 Android 文件夹下寻找您的 build.gradle 文件。将 minSdkVersion 替换为 21。它的代码应该如下所示
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}
我试过以下链接
http://developer.android.com/intl/es/tools/building/multidex.html
Android Studio TransformException : Error:Execution failed for task ':app:transformClassesWithDexForDebug'
我的gradle构建文件如下。
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "appId"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile files('libs/rt.jar')
compile 'com.android.support:multidex:1.0.0'
}
我的清单如下。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="packageName">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的activity文件如下。
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
经过这一切,我仍然得到以下错误。
Error:Execution failed for task
':app:transformClassesWithMultidexlistForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_72\bin\java.exe'' finished with non-zero exit value 1
回答
我必须在应用级别执行以下操作
- 删除 rt.jar 作为库
- 从 build.gradle 中删除
- 清理并构建项目。
compile files('libs/rt.jar')
感谢 George Mulligan 指出。
我不确定 Windows OS 和直线 JAVA 是否相同。我在 cordova run android
中遇到了同样的问题,它总是在 Mac 中失败。所以我将以下内容添加到我的 build.gradle 文件中并且构建通过了,并且我能够在模拟器上进行测试。在 android 部分下添加编译信息,在默认配置下添加 multidex
android {
compileSdkVersion 23
buildToolsVersion "23"
}
defaultConfig {
multiDexEnabled true
}
请注意构建版本仅为 23 而不是 23.0.1
我知道通过了。但我有同样的问题。 消息是这样的:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. java.io.IOException: Can't write [D:...app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:....\support-core-ui-27.1.1.aar\eadf2be3981e05166424b72b4128200e\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager.class]))
我搜索了很多但没有找到。 我通过在 gradle:
中添加以下行来解决它implementation 'com.android.support:support-v4:27.0.2'
我找到了快速修复方法。但可能有更好的解决方案。
changing minSdkVersion means it will not gonna work for below the sdk version
在您的 Android 文件夹下寻找您的 build.gradle 文件。将 minSdkVersion 替换为 21。它的代码应该如下所示
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}