Java :app:transformClassesWithMultidexlistForDebug失败
我尝试了以下链接 我的gradle构建文件如下所示Java :app:transformClassesWithMultidexlistForDebug失败,java,android,build.gradle,android-multidex,Java,Android,Build.gradle,Android Multidex,我尝试了以下链接 我的gradle构建文件如下所示 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '23.0.1' defaultConfig { applicationId "appId" minSdkVersion 14 targetSdkVersion 23
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>
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);
}
}
我的舱单如下
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>
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中删除
编译文件('libs/rt.jar')
- 清洁和建设项目
感谢George Mulligan指出了这一点。我不确定这是否适用于使用纯JAVA的Windows操作系统。我在cordova运行的android上也遇到了同样的问题,而且在Mac上总是失败。因此,我在build.gradle文件中添加了以下内容,构建通过了,并且我能够在模拟器上进行测试。在android部分下添加编译信息,在默认配置下添加multidex
android {
compileSdkVersion 23
buildToolsVersion "23"
}
defaultConfig {
multiDexEnabled true
}
请注意,构建版本仅为23,而不是23.0.1,我知道它已通过。但我也有同样的问题。 信息是这样的: 错误:任务“:app:transformClassesWithMultidexlistForDebug”的执行失败。 java.io.IOException:无法写入[D:…app\build\intermediates\multi-dex\debug\componentClasses.jar](无法读取[C:…..\support-core-ui-27.1.1.aar\eadf2be3981e0516424b72b412800e\jars\classes.jar(;;**.class)](重复的zip条目[classes.jar:android/support/v4/view/ViewPager$1.class])) 我找了很多,但什么也没找到。 我通过在gradle中添加以下行来解决此问题:
implementation 'com.android.support:support-v4:27.0.2'
我找到了一个快速解决办法。但也许有更好的解决办法 更改minSdkVersion意味着它将无法在低于sdk版本的情况下工作 在Android文件夹下查找build.gradle文件。将Minsdk版本更换为21。它的代码应该如下所示
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}
多亏了在您发现错误的消息窗口中再向上滚动一点。可能会出现一条更有用的错误消息,说明发生了什么错误。嗨,乔治,下面是我的堆栈跟踪。这里没有什么问题。我是Android Studio noob。您是否正在将显示的完整消息添加到帖子中?我还没有在那里看到它。嗨@george mulligan,下面是我的堆栈跟踪。我是安卓工作室的noob。我没有发现任何问题。所有其他:app:显示为最新:app:TransformClasses with MultidexListForDebug准备输出jar[E:\AndroidStudioProjects\MADS\app\build\intermediates\multi-dex\debug\componentClasses.jar]从程序jar复制资源[E:\AndroidStudioProjects\MADS\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]:app:TransformClasses With Multidexlist ForDebug失败为什么你有
rt.jar
作为依赖项?如何做。请提供通过cordova clean and build项目实现的更多详细信息。非常感谢。我不知道问题出在哪里,但已经解决了:)欢迎,但我们需要一些可以在minSdkVersion 16上运行的修复。。。