Gradle Build Error - Program type already present

waqaslam :

I'm trying to build an android project which has two modules, one is an application and the other is a library. Both modules have gson-2.8.5.jar files included in their respective libs folder. When I deploy the application, it fails during build with the following error message.

Program type already present: com.google.gson.FieldNamingPolicy$6
Message{kind=ERROR, text=Program type already present: com.google.gson.FieldNamingPolicy$6, sources=[Unknown source file], tool name=Optional.of(D8)}

However, I tested my setup by replacing hard provided .jar files dependencies with gradle's (implementation 'com.google.code.gson:gson:2.8.5') and it worked fine. But I have to use jar files in libs folder since I'm going to use Android.mk file to build the entire project later on, therefore can't depend on gradle injected dependency.

I searched about this error but unfortunately didn't find any useful results. Hope someone knows how to fix this.

waqaslam :

Got it fixed. Seems like I had to mark transitive property to false for my included module.

Before:

implementation project(path: ':myLib')

After (fix):

implementation project(path: ':myLib', transitive: false)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=103475&siteId=1