Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: import gson issue
hi
i try import gson, like how-import-gson-library-corfrectly
i modify build.gradle
compileInclude group: "com.google.code.gson", name: "gson", version: "2.9.0"
bnd.bnd
Bundle-Name: DEM
Bundle-SymbolicName: demo.srg
Bundle-Version: 1.0.0
Export-Package:\
demo.srg.constants,\
com.google.gson.*
Import-Package:\
com.google.gson.*; version='2.9.0',\
*
but doesn't work
error message from gradle build
error : Classes found in the wrong directory: {META-INF/versions/9/module-info.class=module-info}
error when server run up
2022-07-15 04:44:34.233 ERROR [Framework Event Dispatcher: Equinox Container: 6ea82b61-4cc8-443a-8df4-c91c4c11d9da][Framework:47] FrameworkEvent ERROR
com.liferay.portal.kernel.log.LogSanitizerException: org.osgi.framework.BundleException: Could not resolve module: com.pac.ci.srg [1597]_ Unresolved requirement: Import-Package: com.google.gson; version="[2.9.0,3.0.0)"_ [Sanitized]
is there anything i missed?
thanks in advance
You need to exclude the packages like this with exclamation sign "!" and read this article https://liferay.dev/blogs/-/blogs/gradle-compile-vs-compileonly-vs-compileinclude Import-Package: \ !com.google.gson,\
*
and don't forgot to put * in the last line.