Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Build Error - Program type already present

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.

like image 726
waqaslam Avatar asked Feb 20 '26 10:02

waqaslam


1 Answers

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)
like image 87
waqaslam Avatar answered Feb 21 '26 23:02

waqaslam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!