Comments (4)
But since you added
-dontwarn javax.swing.** -dontwarn java.awt.**
the build was not failing; it's usually fine to ignore some warnings but they should give you an indication of classes that are missing and that should potentially be provided as libraryjars.
Agreed. which made it harder to debug and caused unexpected behavior.
It's a common issue since many tutorials and examples online use ignorewarnings
or ignore the warnings from the JDK which is something I didn't quite understand
I appreciate your guidance on this.
from proguard.
Not directly related: it seems this line is needed even when using Shadow JAR:
// This will include the Kotlin library jars, it will be needed even though Shadow JAR already includes it
// to solve all warnings that are related to Kotlin without ignoring them
injars(sourceSets.main.get().compileClasspath)
To solve all warnings coming from Kotlin library without using -dontwarn kotlin.**
in proguard.pro
from proguard.
It seems this issue is from my side (incorrect configurations), I didn't include java.desktop.jmod
from the JDK using libraryjars
which is needed to avoid such issues, the final Proguard task will be:
tasks.register<proguard.gradle.ProGuardTask>("proguard") {
dependsOn(tasks.shadowJar)
configuration("proguard.pro")
injars(tasks.shadowJar.flatMap { it.archiveFile })
outjars(project.layout.buildDirectory.file("proguard-obfuscated.jar"))
val javaHome = System.getProperty("java.home")
// Automatically handle the Java version of this build.
if (System.getProperty("java.version").startsWith("1.")) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars("$javaHome/lib/rt.jar")
} else {
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars(
// filters must be specified first, as a map
mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"),
"$javaHome/jmods/java.base.jmod"
)
// Needed to support Java Swing/Desktop
libraryjars(
mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"),
"$javaHome/jmods/java.desktop.jmod",
)
}
allowaccessmodification()
dontobfuscate()
dontoptimize()
verbose()
// This will include the Kotlin library jars, Shadow JAR already includes it
libraryjars(sourceSets.main.get().compileClasspath)
printmapping(project.layout.buildDirectory.file("proguard-mapping.txt"))
}
And proguard.pro
:
-verbose
-keepattributes *Annotation*
-keep class kotlin.Metadata { *; }
# Entry point to the app.
-keep class MainKt { *; }
This issue can still be useful for anyone who has similar issues as it solves other unrelated issues and can be useful to get started with Proguard on Kotlin/JVM in general.
from proguard.
Hi @ellet0 ! Glad you solved your issue!
In these kind of cases, you would normally see "Referenced class not found" warnings or similar which by default would fail the build.
But since you added -dontwarn javax.swing.** -dontwarn java.awt.**
the build was not failing; it's usually fine to ignore some warnings but they should give you an indication of classes that are missing and that should potentially be provided as libraryjars.
from proguard.
Related Issues (20)
- Java Formats and locales do not work
- Caused by: java.lang.ClassNotFoundException: proguard.optimize.gson._OptimizedJsonWriter HOT 1
- Modular program
- ProGuard writes wrong version code in zip files
- Reproducible Build Support HOT 1
- How to find root issue relate "It appears you are missing some classes resulting in an incomplete class hierarchy" HOT 1
- Generics from interfaces are removed HOT 7
- When I use Spring Framework 6.x, I can mix up packaging normally, but the controller reports an error after running it HOT 1
- Annotation with parameters
- `code/simplification/object` optimisation causing `NullPointerException`
- application-kotlin example doesn't support using Kotlin imports HOT 2
- Method of lambda expression passed as an instance of an interface defined in obfuscated library is not obfuscated correclty
- kotlin 2 support HOT 1
- How to skip some jars in multi jars
- Feature request: Support for Intellji IDE Plugin
- java.lang.VerifyError: Expecting a stackmap frame at branch target 14 HOT 2
- Poor performance when overrunning a large obfuscation dictionary HOT 1
- Reproducible output jar
- java.lang.VerifyError: Bad type on operand stack for Kotlin 2.0 and KotlinX Serialization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proguard.