yGuard

35 views
Skip to first unread message

Chris Topher

unread,
Sep 10, 2018, 2:58:52 PM9/10/18
to java-ide-droid
Greetings.

Is it possible to use yGuard to protect an Android APK?

Tom Arn

unread,
Sep 10, 2018, 3:16:41 PM9/10/18
to java-ide-droid
Hi
Yes, I once made yGuard work on Android with JavaIDEdroid (PRO): https://github.com/t-arn/java-ide-droid/wiki/How-to-use-yGuard
I don't know if the current versions will still work.


Best regards

Chris Topher

unread,
Sep 12, 2018, 6:26:12 PM9/12/18
to java-ide-droid
I tried with current version of yGuard 2.6 and it chokes with all kinds of exceptions when creating the module.

I can not find 2.5.1 anywhere- do you have a copy?

Chris Topher

unread,
Sep 12, 2018, 6:26:12 PM9/12/18
to java-ide-droid
Hi Tom,

Thanks for your reply. The example was for a Java program, not a android apk compile. Just wanting to get some guidance.

I bought the pro version just for this ability. I develop 99% on a android device and need to protect my code.

Are the steps and different for using yGuard with android build?

Chris Topher

unread,
Sep 12, 2018, 6:26:12 PM9/12/18
to java-ide-droid
Errors:

Running script /storage/extSdCard/JavaIDE/HelloJava_2-0-0/create_yguard_module.bsh

Protected script mode: INACTIVE


***** Creating yguard module ...
JavaRunner arguments:
/sdcard/.JavaIDEdroid/JarOutputStreamFix_1-0-0.zip
/sdcard/.JavaIDEdroid/yguard_2-5-1_androidFix.jar

Extracting assets to /sdcard/.JavaIDEdroid/temp1536610287054/
Extracting jar content to /sdcard/.JavaIDEdroid/temp1536610287054/

Dexing part #1 (52%), max dex size: 300 KB
Dx arguments:
--dex
--core-library
--incremental
--output=/sdcard/.JavaIDEdroid/yguard_2-5-1_androidFix.jar.dex.zip
/sdcard/.JavaIDEdroid/JarOutputStreamFix_1-0-0.zip
/sdcard/.JavaIDEdroid/temp1536610287054/


UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android26.dx.command.dexer.Main.processClass(Main.java:753)
at com.android26.dx.command.dexer.Main.processFileBytes(Main.java:719)
at com.android26.dx.command.dexer.Main.access$3(Main.java:690)
at com.android26.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1646)
at com.android26.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android26.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android26.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android26.dx.command.dexer.Main.processOne(Main.java:673)
at com.android26.dx.command.dexer.Main.processAllFiles(Main.java:575)
at com.android26.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android26.dx.command.dexer.Main.run(Main.java:277)
at com.android26.dx.command.dexer.Main.main(Main.java:245)
at com.android26.dx.command.Main.main(Main.java:108)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at ch.tanapro.JavaIDEdroid.r.a(SourceFile:110)
at ch.tanapro.JavaIDEdroid.j.f(SourceFile:476)
at ch.tanapro.JavaIDEdroid.k.fnDx(SourceFile:79)
at ch.tanapro.JavaIDEdroid.l.a(SourceFile:371)
at ch.tanapro.JavaIDEdroid.l.a(SourceFile:225)
at ch.tanapro.JavaIDEdroid.l.a(SourceFile:403)
at ch.tanapro.JavaIDEdroid.j.g(SourceFile:750)
at ch.tanapro.JavaIDEdroid.k.fnRunJava(SourceFile:83)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHVariableDeclarator.eval(Unknown Source)
at bsh.BSHTypedVariableDeclaration.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHIfStatement.eval(Unknown Source)
at bsh.BSHIfStatement.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.source(Unknown Source)
at bsh.Interpreter.source(Unknown Source)
at ch.tanapro.JavaIDEdroid.j.a(SourceFile:666)
at ch.tanapro.JavaIDEdroid.a.a(SourceFile:65)
at ch.tanapro.JavaIDEdroid.a.doInBackground(SourceFile:1)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: com.android26.dx.cf.iface.ParseException: class name (java/util/jar/JarOutputStream) does not match path (bin/test/JarOutputStreamFix/classes/java/util/jar/JarOutputStream.class)
at com.android26.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
at com.android26.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android26.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android26.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android26.dx.command.dexer.Main.parseClass(Main.java:765)
at com.android26.dx.command.dexer.Main.access$6(Main.java:760)
at com.android26.dx.command.dexer.Main$ClassParserTask.call(Main.java:1685)
at com.android26.dx.command.dexer.Main.processClass(Main.java:751)
... 50 more
warning: Ignoring InnerClasses attribute for an anonymous inner class
(c.e.e$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
1 error; aborting

Done in 53 sec.

ExitValue: 1
Error during dx, deleting target file /sdcard/.JavaIDEdroid/yguard_2-5-1_androidFix.jar.dex.zip
java.io.IOException: Error when dexing .jar file!
Deleting directory tree /sdcard/.JavaIDEdroid/temp1536610287054/

Done in 55 sec.

ExitValue: 3

Total script run time: 55 sec.

Script ExitValue: 3

Chris Topher

unread,
Sep 12, 2018, 6:26:12 PM9/12/18
to java-ide-droid
I contacted yWorks and they were gracious enough to send me 2.5.1 which you used in your tutorial.

It fails to build a module as well.

Please advise.

My ONLY reason paying the high amount for PRO was the ub tutorial on yGuard. Please advise.
Message has been deleted

Tom

unread,
Sep 12, 2018, 6:46:28 PM9/12/18
to java-ide-droid
I have uploaded the yguard 2.5.1 binary module to the download area: https://github.com/t-arn/java-ide-droid/wiki/3.-Downloads
The first time you run it, you will need to add the module hash to it. Make sure you set your personal module salt first (if you want to use one for your modules)

Best regards
Tom

Chris Topher

unread,
Sep 12, 2018, 7:25:54 PM9/12/18
to java-ide-droid
Tom,

Thank you. The HelloJar compiles with yGuard. Nice.

Now I need help, I've tried to figure out where to use yGuard in the android build process, and well, I'm not new to development, just new to command line compiling.

Can you please modify your HelloAndroid to use yGuard. If I am able to see how it's added to your project, I will e able to reproduce in my own.

Also, HelloAndroid doesn't have a . project file.

Thank you for your time.

Tom

unread,
Sep 15, 2018, 5:31:36 AM9/15/18
to java-ide-droid
The yGuard command must be added after the compiling and before the dexing.

Tom

Chris Topher

unread,
Sep 15, 2018, 9:36:29 PM9/15/18
to java-ide-droid
I tried everything, not sure what I am doing wrong.

Can you please provide a working example Tom?

Chris Topher

unread,
Sep 20, 2018, 10:34:34 AM9/20/18
to java-ide-droid
Any luck? I'm having none. :-(

Chris Topher

unread,
Oct 6, 2018, 12:00:32 AM10/6/18
to java-ide-droid
I have tried about everything. I need help with this please.

Thank you.

Tom

unread,
Oct 9, 2018, 12:05:16 PM10/9/18
to java-ide-droid
Hello Chris

I have added a demo app to the download area of JavaIDEdroid which shows how to use yGuard to obfuscate Android apps: HelloAndroid-with-yguard.zip

For more details, see here:

In the <keep> elements of the yguard task, I added all classes that extend the Activity class, because these classes are referenced in AndroidManifest.xml and need to be found under the original class name. In your own app, you might need to add more <keep> elements to make it run properly.

Good luck!
Tom
Reply all
Reply to author
Forward
0 new messages