ProGuard混淆 - java.lang.NoSuchMethodError:getPointer(ProGuard obfuscation - java.lang.NoSuchMethodError: getPointer)
我试图混淆我写的游戏。 我把它缩小到一个非常基本的项目来说明问题(项目可以在这里找到: https : //github.com/dschneider/libgdx-proguard-test )。
您必须在终端中安装ant并运行make desktop来编译和混淆项目。 尝试之后运行混淆的jar时会发生以下错误:
Exception in thread "main" java.lang.NoSuchMethodError: getPointer at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1894) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851) at java.lang.Runtime.load0(Runtime.java:795) at java.lang.System.load(System.java:1062) at org.lwjgl.Sys$1.run(Sys.java:70) at java.security.AccessController.doPrivileged(Native Method) at org.lwjgl.Sys.b(Sys.java:66) at org.lwjgl.Sys.c(Sys.java:95) at org.lwjgl.Sys.<clinit>(Sys.java:112) at org.lwjgl.openal.AL.<clinit>(AL.java:59) at com.badlogic.gdx.backends.openal.OpenALAudio.<init>(OpenALAudio.java:70) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:82) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:64) at com.libgdxproguard.test.Main.main(Main.java:14)
我错过了什么吗? 当我告诉ProGuard不要混淆代码时,它会在之后运行。 显然有些东西被混淆了什么不应该被混淆,但我不知道如何解决这个错误。
I am trying to obfuscate a game that I wrote. I slimmed it down to a very basic project to illustrate the problem (the project can be found here: https://github.com/dschneider/libgdx-proguard-test).
You have to install ant and run make desktop in terminal to compile and obfuscate the project. The following error occurs when trying to run the obfuscated jar afterwards:
Exception in thread "main" java.lang.NoSuchMethodError: getPointer at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1894) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851) at java.lang.Runtime.load0(Runtime.java:795) at java.lang.System.load(System.java:1062) at org.lwjgl.Sys$1.run(Sys.java:70) at java.security.AccessController.doPrivileged(Native Method) at org.lwjgl.Sys.b(Sys.java:66) at org.lwjgl.Sys.c(Sys.java:95) at org.lwjgl.Sys.<clinit>(Sys.java:112) at org.lwjgl.openal.AL.<clinit>(AL.java:59) at com.badlogic.gdx.backends.openal.OpenALAudio.<init>(OpenALAudio.java:70) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:82) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:64) at com.libgdxproguard.test.Main.main(Main.java:14)
Am I missing something? When I tell ProGuard to not obfuscate the code, it works afterwards. Apparently something is obfuscated what shouldn't be obfuscated, but I am not sure how to solve this error.
原文:https://stackoverflow.com/questions/20910593
最满意答案
实际上,我以前很想这样做,但只是想出了这个想法。 你可以翻译
trait T(implicit impl: ClassName) { def foo = ... // using impl here }
[EDITED:原始版本未提供对其他方法的隐式访问]
trait T { // no need to ever use it outside T protected case class ClassNameW(implicit val wrapped: ClassName) // normally defined by caller as val implWrap = ClassNameW protected val implWrap: ClassNameW // will have to repeat this when you extend T and need access to the implicit import implWrap.wrapped def foo = ... // using wrapped here }
Actually, I've wanted this quite often before, but just came up with this idea. You can translate
trait T(implicit impl: ClassName) { def foo = ... // using impl here }
to [EDITED: original version didn't provide access to implicit for other methods]
trait T { // no need to ever use it outside T protected case class ClassNameW(implicit val wrapped: ClassName) // normally defined by caller as val implWrap = ClassNameW protected val implWrap: ClassNameW // will have to repeat this when you extend T and need access to the implicit import implWrap.wrapped def foo = ... // using wrapped here }
相关问答
更多-
实际上,我以前很想这样做,但只是想出了这个想法。 你可以翻译 trait T(implicit impl: ClassName) { def foo = ... // using impl here } [EDITED:原始版本未提供对其他方法的隐式访问] trait T { // no need to ever use it outside T protected case class ClassNameW(implicit val wrapped: ClassName) // nor ...
-
隐式参数和泛型类型(implicit parameters and generic types)[2022-08-28]
当你调用foo时,你没有为foo提供一个类型参数(由于以下原因,没有其他方法可以推断它),因此编译器无法找到正确的,并且正确的隐含。 你有一个隐含的bar: String => Int在范围内,但你也在 Predef中有一个implicits创建=:=和<:<实例,它们都扩展A => B ,并创建隐式String => A s。 编译器正在为foo寻找一些隐式函数String => T ,但它不确定哪一个,并且你有多个范围。 bar不会优先,因为您没有指定它正在寻找的特定String => T 这将有效: ... -
无法处理“traits不能具有上下文绑定的类型参数”(Unable to deal with “traits cannot have type parameters with context bound”)[2021-10-21]
这不会起作用,因为宏实现的方法Json.writes没有足够的关于T信息。 No unapply function found未应用的No unapply function found不是您将获得的唯一错误消息,它只是第一个。 如果你想使用duck typing,你应该使用T <: {def unapply(a: T): Option[T]} 。 使用T: {def unapply(a: T): Option[T]}你试图添加一个{def unapply(a: T): Option[T]}[T]类型的隐式参 ... -
构造函数使用多个参数是否需要显式关键字?(Is the explicit keyword needed with a constructor taking more than one parameter?)[2022-12-07]
如果我们有一个具有两个或更多参数的构造函数,那么会explicit阻止的是什么? 没有。 If we have a constructor that takes two or more parameters, what will explicit prevent? Nothing. -
尝试 class Child(a: Int)(implicit val str: String, map: Map[String,String]) extends Parent(a) with ClassTrait { def doSth2 = doSth * 10 } (见我添加的val ) 或者用case class 。 然后他们将是田野。 替代方法可能是不使它们隐式,并在伴随对象中使用apply方法,该方法需要使用implicits来设置它们。 但是你仍然需要创建它们,你的当前代码在技术上只 ...
-
你忘了指定std::enable_if的第二个参数(默认为void ) template
Holder(typename std::enable_if::value && std::is_base_of< A , T>::value, T>::type&& val) : b (std::forward (val)) {} 但无论如何, T将处于不可导出的背景下。 你可能会这样做 templ ... -
需要隐式参数(Implicit parameters required)[2022-03-10]
我建议在隐式读写定义上设置一个显式类型,如下所示: implicit val biosChannelReads: Reads[BiosChannel] = { val ccwBiosChannel = Json.reads[CCWBiosChannel] val nnBiosChannel = Json.reads[NNBiosChannel] __.read[CCWBiosChannel](ccwBiosChannel).map(x => x : BiosChannel) | __.r ... -
复制初始化类类型的对象时,复制构造函数需要可用,即使复制被省略也是如此。 g ++拒绝你的程序是正确的; 您的旧版本的MSVC不正确接受它。 您可能能够提供没有定义的复制构造函数的声明,因为在链接时将忽略对它的调用或以其他方式失败。 但这可能有些令人困惑。 最明显的解决方案是使用直接初始化,正如您已经观察到的那样工作正常。 When you copy-initialize an object of class type, the copy constructor needs to be available, ...
-
Struct隐式默认构造函数与无参数构造函数(Struct Implicit Default Constructor vs. Parameterless Constructor)[2022-01-16]
隐式默认构造函数是无参数构造函数,它由编译器自动创建。 您无法创建无参数构造函数的原因是因为默认构造函数已存在。 我不知道为什么他们选择这样做,以及为什么你不允许覆盖它。 The implicit default constructor is the parameterless constructor which is automatically created by the compiler. The reason you can't create a parameterless constructor ... -
scala如何确定TreeSet构造函数的隐式类型参数(How scala determines implicit type parameters for TreeSet constructor)[2023-08-02]
问题的核心 如果你用-Xlog-implicits运行这个例子(对于sbt scalacOptions := Seq( "-Xlog-implicits" ) ),你会看到很多这样的[info]消息 math.this.Ordering.Tuple6不是scala.math.Ordering [A]的有效隐式值,因为:[info]为scala.math.Ordering [T1]类型分散隐式扩展 这基本上适用于math.this.Ordering所有类型。从简单的Boolean到Iterables和Opti ...