【问题标题】:Error while integrating AppDynamics: transformClassesWithMultidexlistForLiveDebug集成 AppDynamics 时出错:transformClassesWithMultidexlistForLiveDebug
【发布时间】:2017-01-30 10:00:03
【问题描述】:

我正在尝试通过我的 gradle 将应用程序性能监控工具与我的 Android 应用程序集成失败说

Error:Execution failed for task ':app:transformClassesWithMultidexlistForLiveDebug'.
> java.util.NoSuchElementException (no error message)

下面是我的 gradle 根 gradle 文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.appdynamics:appdynamics-gradle-plugin:4.+'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

这是我应用的 gradle 文件,

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"


    defaultConfig {
        applicationId "com.app.abc"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1"
        multiDexEnabled true
    }

    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }

    signingConfigs {
        config {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('xxx')
            storePassword 'xxx'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
        }
        debug {
            debuggable true
            minifyEnabled false
        }
    }

    afterEvaluate {
        tasks.matching {
            it.name.startsWith('dex')
        }.each { dx ->
            if (dx.additionalParameters == null) {
                dx.additionalParameters = []
            }
            dx.additionalParameters += "--set-max-idx-number=55000" 
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

dependencies {
    ...
    compile 'com.appdynamics:appdynamics-runtime:4.+'
}

我已经启用了 Multidex 标志,但它在运行应用程序时给我带来了问题。

而且,我的应用程序类中也有

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

【问题讨论】:

    标签: android appdynamics android-studio-2.2.3


    【解决方案1】:

    我尝试添加多 dex,但没有明智地为每个 dex 文件提供任何最小或最大方法计数。我尝试过简单地添加多 dex 并能够构建。是的!我也可以构建应用程序。

    主要变化在于afterEvaluateincremental true 中的dexoption

    build.gradle

    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.3'    
        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 18
            renderscriptTargetApi 18
            //renderscriptSupportModeEnabled true
            // To enable MultiPle dex
            multiDexEnabled true
        }
        dexOptions {
            // Option to handle multi dex
            incremental true
            javaMaxHeapSize "4g" // try with 2g as it worked for my case its working in both cases
            // here 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
        }
        packagingOptions {
    
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
    
        }
        signingConfigs {
            Release {
                keyAlias 'helloworld'
                keyPassword 'helloworld'
                storeFile file('../helloworld')
                storePassword 'helloworld'
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'),
                        'proguard-project.txt'
            }
            debug {
                signingConfig signingConfigs.Release
            }
        }
    }
    
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
    
          compile 'com.android.support:multidex:1.0.1'
        compile 'com.android.support:appcompat-v7:23.3.0'
        compile 'com.android.support:design:23.3.0'
    
        compile 'com.google.android.gms:play-services-maps:8.4.0'
        compile 'com.google.android.gms:play-services-ads:8.4.0'
        compile 'com.google.android.gms:play-services-analytics:8.4.0'
        compile 'com.google.code.gson:gson:2.6'    
        compile 'com.github.bumptech.glide:glide:3.7.0'
        compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
        compile 'com.squareup.okhttp3:okhttp:3.2.0'    
        compile 'com.appdynamics:appdynamics-runtime:4.+'
    }
    afterEvaluate {
        tasks.matching {
            it.name.startsWith('dex')
        }.each { dx ->
            if (dx.additionalParameters == null) {
                dx.additionalParameters = []
            }
            dx.additionalParameters += '--multi-dex' // enable multidex without giving minimum or maximum limit
        }
    }
    

    应用程序的父级 gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.3'
            classpath 'com.appdynamics:appdynamics-gradle-plugin:4.+'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    如果上面的事情仍然存在问题,只需检查您的依赖层次结构是否添加了任何其他额外的依赖(根据您的 build.gradle packagingOptions 应该有一些其他依赖)。不确定但可能因为内部库冲突它没有继续创建 dexfile 或构建。

    如果有什么请告诉我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-08
      • 2017-02-06
      • 2013-09-06
      • 1970-01-01
      相关资源
      最近更新 更多