问题描述
我在这里看到了这么多线程,但仍然找不到有效的解决方案.
I watched so many threads here and still didnt find working solution.
当我想构建APK时,出现以下主要错误:
几乎没有其他错误,但是有时会出现,其中一些错误:
There is few more errors, but then apear only sometimes, some of them:
错误:在 com.android.dx.command.dexer.Main.processFileBytes(Main.java:723)
Error: at com.android.dx.command.dexer.Main.processFileBytes(Main.java:723)
错误:在 com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
Error: at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
错误:java.lang.OutOfMemoryError:超出了GC开销限制
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
我尝试过的事情:
在build.gradle中
In build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.biif.volunteer"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
dependencies {
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1')
}
在清单中
另外,我关闭了即时运行(在这里看到一个线程).
Plus I turned off Instant run (saw in one thread here).
没有任何帮助:(有什么想法吗?谢谢您的帮助:)
推荐答案
我在项目中包含gradle.properties文件,其内容如下:
I included gradle.properties file in the project with:
org.gradle.jvmargs=-Xmx10248m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
它有效.
这篇关于生成APK-错误-app:transformClassesWithDexForDebug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!