Hello fellow Programmers,
I’m having trouble building my libgdx Game for Android with freetype font dependencies.
Libgdx version: 1.9.8
Gradle version: 3.2.0
Android Studio version: 3.1.4
Even without any dependencies for freetype font declared in the root build.gradle file and cleaning of the project I get the following Error when trying to build for Android:
Execution failed for task ':android:transformResourcesWithMergeJavaResForDebug'.
More than one file was found with OS independent path 'libgdx-freetype.dylib'
Following the description for integrating freetype font I added the following dependencies, but I still get the Error above.
project(":desktop") {
…
dependencies {
…
//freetype font
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
…
dependencies {
…
//freetype font
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
}
}
project(":core") {
…
dependencies {
…
//freetype font
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
}
}
I’ve tried every possible combination of compile/implementation/api but nothing seems to work.
After some searching in similar Posts I added the following lines to the build.gradle file in the Android Project:
android {
…
packagingOptions {
…
pickFirst 'libgdx-freetype.dylib'
pickFirst 'libgdx-freetype64.dylib'
pickFirst 'gdx-freetype.dll'
pickFirst 'gdx-freetype64.dll'
}
…
}
And now I get the following Error when trying to build for Android:
Execution failed for task
':android:transformDexArchiveWithExternalLibsDexMergerForDebug'.
Program type already present:
com.badlogic.gdx.graphics.g2d.freetype.FreeType$Face
Any help resolving this issue would be much appreciated.
EDIT:
Created a new Project, copied my code and now it's working...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…