阿里百川、友盟app:transformClassesWithDexForDebug

友盟集成新能监控的时候

打开这个开关

//是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启,false则不开启启动插件
isAutoTrack = true

app:transformClassesWithDexForDebug编译长达2分钟 

关闭后恢复正常

相信大家在Android的开发过程中都免不了要集成第三方的项目、最近我就集成了阿里百川的SDK、其中就遇到了各种问题、今天终于集成成功了、困扰我最久的问题就是transformClassesWithDexForDebug、详细的Log如下

Error:Execution failed for task ´:app:transformClassesWithDexForDebug´.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

现在就记录一下困扰我最久的问题的解决方案、希望大家少走弯路、这个问题主要的原因就是引入的Libary与现有的工程中的某些Libs重复了、请详细检查并确保所有使用的lib只有一份、比如v4、v7、utdid.jar等等、另外如果使用android的官方支持库请参见、http://developer.android.com/tools/support-library/features.html

如果还是有问题就可以使用如下配置来解决问题

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    //Enabling multidex support.
    multiDexEnabled true
}
dependencies {
    compile ´com.android.support:multidex:1.0.0´
}

然后在manifest里面这样引入、如果有自定义AppApplication、就继承这个类就好了

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

另外还有可能就是JDK 1.8 版本问题、这并不像是偶然现象,于是怀疑 Gradle 与 JDK 1.8 存在兼容性问题、尝试将工程依赖的 JDK 版本降到 1.7

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

这个时候有可能还是会有这个错误、那么再可以在app.bulid里面加上这句、再Rebuild、之后再运行就行了、4g可以看电脑配置修改(2g、3g、6g、8g)

dexOptions {
    javaMaxHeapSize "4g"
}

猜你喜欢

转载自blog.csdn.net/cao2884388/article/details/81905071