如何解决“TransformException:重复输入”错误?

时间:2017-07-01 09:15:40

标签: java android xml android-studio

Gradle sync在运行时没有显示任何错误,但是当我尝试运行应用程序时,它显示错误。

我尝试删除重复的库并在我的MainActivity中添加了 apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.0" defaultConfig { applicationId "com.example.kanwal.calculator_test" minSdkVersion 14 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'} } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:multidex:1.0.1' androidTestCompile('com.android.support.test.espresso:espresso core:2.2.2',{ exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile files('libs/javaluator-3.0.1.jar')} ,并试图清理并运行该项目,但没有运气。

错误:

  

错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / fathzer / soft / javaluator / demo / DemoApplet.class

我的gradle代码:

#include<stdio.h>
int main(){
   int a[10],i,j,arr_size;

   printf("Enter the size of the array");
   scanf("%d",&arr_size);

   printf("Enter the array:");
   for(i=0;i<arr_size;i++)
   scanf("%d",&a[i]);

   //here key is 42
   //so we'll find the key and print the elements up to that
   for(j=0;j<arr_size;j++){
      if(j==42)
        break;

      //loop for the array up to the key
      for(i=0;i<j;i++)
      printf(" %d",a[i]);  
   }

   return 0; 
}

2 个答案:

答案 0 :(得分:0)

从jar中排除重复的包:

compile('libs/javaluator-3.0.1.jar') {
exclude module: 'demo';}

尝试在proyect的根目录中的终端上运行它:

./gradlew clean

答案 1 :(得分:0)

您已将此行添加到gradle

compile fileTree(include: ['*.jar'], dir: 'libs')

您可以删除冗余行或删除上面的行。

删除上述行

enter image description here