无法运行应用程序错误:任务执行失败':app:transformClassesWithDexForDebug'

时间:2016-03-02 13:13:59

标签: android android-studio build.gradle dex

当我尝试运行我的应用时,我收到此错误

  

错误:任务':app:transformClassesWithDexForDebug'的执行失败。   com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files \ Java \ jdk1.8.0_72 \ bin \ java.exe''以非零退出值2结束

我尝试了这里提到的所有可能的解决方案Error:Execution failed for task ':app:transformClassesWithDexForDebug'

  1. 我没有得到任何重复的lib
  2. 将堆大小增加到1024 MB
  3. 清洁项目
  4. 关闭所有其他工作室窗口
  5. 请在下面找到我的build.gradle

        apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.dapl.shoppingapp"
            minSdkVersion 15
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    repositories {
        maven { url "https://jitpack.io" }
        mavenCentral()
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile files('libs/quickblox-android-sdk-chat-2.5.jar')
        compile files('libs/quickblox-android-sdk-core-2.5.jar')
        compile files('libs/quickblox-android-sdk-messages-2.5.jar')
        compile 'com.android.support:support-v4:23.1.1'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'com.google.android.gms:play-services:8.3.0'
        compile 'org.lucasr.twowayview:twowayview:0.1.4'
        compile 'com.google.android.gms:play-services-gcm:8.3.0'
        compile files('libs/apache-httpcomponents-httpcore.jar')
        compile files('libs/httpclient-4.2.3.jar')
        compile files('libs/httpmime-4.2.4.jar')
        compile files('libs/gcm.jar')
        //    compile project(':libraries:viewpager_indicator')
    }
    

    请帮忙!

    通过在defaultConfig中添加multiDexEnabled true来获取此错误

      

    错误:任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。    com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK META-INF / NOTICE.txt中复制的重复文件       File1:C:\ Users \ DAT-Asset-117-PC \ Downloads \ Skype downloads \ ShoppingApp \ ShoppingApp \ app \ libs \ _ httpclient-4.2.3.jar       File2:C:\ Users \ DAT-Asset-117-PC \ Downloads \ Skype downloads \ ShoppingApp \ ShoppingApp \ app \ libs \ apache-httpcomponents-httpcore.jar       File3:C:\ Users \ DAT-Asset-117-PC \ Downloads \ Skype downloads \ ShoppingApp \ ShoppingApp \ app \ libs \ httpmime-4.2.4.jar

    编辑:完成所有这些操作后,我收到了另一个错误

    java.lang.VerifyError: org/lucasr/twowayview/TwoWayView
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                at android.view.LayoutInflater.createView(LayoutInflater.java:594)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                at com.dapl.shoppingapp.tabs.storeTabs.storeTabFragment.StoreTabFragment1.onCreateView(StoreTabFragment1.java:29)
                at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
                at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
                at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
                at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
                at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
                at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
                at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
                at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1474)
                at android.view.View.measure(View.java:16900)
                at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:818)
                at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:495)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
                at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
                at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
                at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
                at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
                at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
                at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2408)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
                at android.view.View.measure(View.java:16900)
                at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:818)
                at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:495)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
                at android.view.View.measure(View.java:16900)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5406)
                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
                at android.widget.LinearLayout.measureVertical(Linear
    

    崩溃:这种双向视图是我的lib。我认为这次崩溃是因为multiDexEnabled true

1 个答案:

答案 0 :(得分:4)

  

Android 5.0及更高版本本身使用名为ART的运行时   支持从应用程序APK文件加载多个dex文件。

添加

  1. multiDexEnabled true
  2. 示例

    defaultConfig {
        ...
        minSdkVersion 15
        targetSdkVersion 23
        ...
    
        // Enabling multidex support.
        multiDexEnabled true
    }
    

    修改 添加此

        android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
    
    }