Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

android studio - Libgdx: More than one file was found with OS independent path 'libgdx-freetype.dylib'

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same error as you.

In my gradle.build file I had this added under my core dependencies :

implementation "com.badlogicgames.gdx:gdx-tools:$gdxVersion" 

I added this to make a texture packer for my game, and I suppose some of the libraries are creating the error when running the program.

just comment it out (I'm using implementation instead of compile because it's depreciated)

//implementation "com.badlogicgames.gdx:gdx-tools:$gdxVersion"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...