如何修复“找不到引用的类com.google.protobuf”?

时间:2019-09-16 02:26:23

标签: java mysql proguard

我一直在尝试使用Proguard并碰壁。我会很好地运行程序,直到它尝试进行SQL连接(在没有proguard的情况下可以正常工作),此时它不与(可读性错误)连接。

我尝试在没有警告的情况下运行,我将获得2万多个与com.google.protobuf相关的未解决的引用或分类。我试图-SQL,java,protobuf以及将MySQL jar作为-libraryjar保留:

  

警告:com.mysql.cj.x.protobuf.MysqlxSql $ StmtExecuteOrBuilder:找不到引用的类com.google.protobuf.ByteString

这是我当前的proguard配置,末尾没有默认内容:

-injars 'C:\Users\Bobby\Desktop\mainApp\mainApp.jar'
-outjars 'C:\Users\Bobby\Desktop\mainApp\mainAppOut.jar'
-libraryjars 'C:\Program Files\Java\jre1.8.0_172\lib\rt.jar'
-libraryjars 'C:\Program Files\Java\jre1.8.0_172\lib\ext\jfxrt.jar'

-classobfuscationdictionary OBF.txt

-dontoptimize
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-renamesourcefileattribute SourceFile
-adaptclassstrings mainApp.mainUI
-adaptresourcefilenames **.properties,**.fxml,**.css
-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF,**.fxml
-dontnote
-dontwarn

##---------------Begin: proguard configuration for JavaFx ----------
-keepclassmembers class * {
    @javafx.fxml.FXML *;
}

-keep,allowobfuscation class mainApp.**

-keep class com.mainApp {
    public static void main(java.lang.String[]);
}
##---------------End: proguard configuration for JavaFX----------
# Keep - Applications. Keep all application classes, along with their 'main' methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver
-keep class com.google.protobuf.** { *; }
java.lang.ClassCastException: com.mysql.cj.b.D cannot be cast to com.mysql.cj.b.j
        at com.mysql.cj.g.K.a(SourceFile:162)
        at com.mysql.cj.g.K.a(SourceFile:196)
        at com.mysql.cj.a.F.a(SourceFile:257)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(SourceFile:196)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
        at mainApp.E.a(SourceFile:159)
        at mainApp.E.c(SourceFile:189)
        at mainApp.E.a(SourceFile:95)
        at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
        at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
        at javafx.base/javafx.event.Event.fireEvent(Unknown Source)
        at javafx.graphics/javafx.scene.Scene$KeyHandler.process(Unknown Source)
        at javafx.graphics/javafx.scene.Scene$KeyHandler.access$1600(Unknown Source)
        at javafx.graphics/javafx.scene.Scene.processKeyEvent(Unknown Source)
        at javafx.graphics/javafx.scene.Scene$ScenePeerListener.keyEvent(Unknown Source)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(Unknown Source)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.View.handleKeyEvent(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.View.notifyKey(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

0 个答案:

没有答案