How can I completely hide classes from Android app package? - java

A while ago I was decompiling an application with apktool in order to understand some snippets. the curious thing was that the application was obfuscated, in fact , the app presented just one class called "Protection.class" full of method like "class.forName" or "class.getMethod"..
Searching on google this is of course the reflection structure, but, seeing some tutorials I ve understood that the classes called by reflection have to be in the application package. And in my case there are no classes except the "protection" one.
In conclusion my questions are:
Is it possible to completly take off classes from package and nevertheless use their methods in someway? Where they are stored in the apk folder (if they are)?
Is there a way to interact with the apk building process in order to obfuscate code or (like in this case) hide classes from package?
NOTE: Proguard can't do it, I have already tested it in the past

Your screenshot shows that this is an app that is protected by DexGuard (the commercial development of ProGuard that goes a lot further).
See also this answer: What methods are being used to protect this Android APK: Reflection? Encryption? How do I reverse engineer it and analyze it?

you can use progaurd to protect apk file from decompiler. also you can use DexGaurd for better security https://www.guardsquare.com/dexguard

You can use progaurd by php library for it and write a progaurd for your project then attach to your app project in gradle file (in android studio) of progaurd file (in eclipse).
for this php has a fine library named php_progaurd

You can use DexGuard for this purpose. DexGuard has, amongst a lot of other features, the ability to encrypt your classes and decrypt them on runtime. These classes will only be present in memory during runtime, so no sourcecode can be reversed from a static APK. DexGuard is a commercial product developed by the creator of ProGuard. I would you suggest you contact them at helloworld#guardsquare.com.
Cheers,
h4

Related

Is it possible to use links file java class files instead of copying them into project in Android Studio?

I have many java class files written by me for common purposes which I need to use very often in my Android projects. These classes (let's call them 'library') has many static methods in them and I call these methods when I need them in my Android Studio projects without any problem
When I create a new Android Studio project I copy all those library files into the Java folder of my new project. So, I can call them with the syntax like classname.methodname() at any time in my projects (in activities, in other java classes, etc)
The question is that this technic causes many independent library files in each project. This means that, when I have added a new method or changed a method, I need to do the same thing at each library files in each project.
As I am new at Android Studio and I am playing with that at the moment, this might be ok. But in real life, this will be impossible in the near future while I was struggling with many projects.
I am sure that, there should be a way to use file links instead of inserting these library files by copying them into the Android projects. So, making changes in a source library file will affect all projects at once. Something like $I directive in the C type languages...
Is this possible and if yes, how?
Thank you...
One good way would be to create your own library/module in android studio.
Here is a link for that : https://developer.android.com/studio/projects/android-library
And another way would be to create your own JAR file.

Reading .qm translation files with Java

I'm trying to read a .qm translation files with Java.
.qm files are binary files. I don't have access to the .ts files.
And I don't find much info on these .qm files.
How are they structured ?
Regards,
There's no documentation that I know of, but if you look at QTranslator::load you should be able to follow the format of the QM file.
You will probably need to reimplement QTranslator in Java, as you need not only the ability to load the files, but also to extract and apply translations in Qt fashion.
As per request of OP:
You could use those files by using the Qt libraries and JNI. By using the translator in a c++ dll you can translate strings easily. However, you cannot extract the files or list the contained translations. But if all you need is the actual translation, this solution should work.
I cannot give a real example, because I only now how it works in theory, I haven't tried it, because it's not trivial. But if you are eager to try it out, the general idea would be:
Create a C++ dll and build it against QtCore. The easiest way is to download Qt from their website qt.io. You can for example create a default library project with QtCreator. Note: Besides Qt5Core.dll, Qt requires other libraries to correctly run. They are all included in the installation, but once you deploy your application, those of course have to be includes as well.
Include JNI to the C++ project and link against it. if you're new to this, here is a nice tutorial: Java Programming Tutorial
Create your wrapper methods. Methods in cpp you can call from java that take java strings, convert them to QString, translate them with QTranslator and convert them back.
Load the library in Java and execute those methods
Important:
First, I don't know how java handles dll dependencies. If you encounter errors while loading the dll, it's probably because dependencies of your dll are not present. Second, Qt typically requires a QCoreApplication running in the main thread for most of it's operations. I tested the translator without such an app, and it worked. So apparently for translations only the app is not required. However, depending on what you do in your dll, I think this is important to know.
If you need more details, feel free to ask.

How to download Packages for Android Studio?

I just started Android Development yesterday and just finished with my first Activity. On running it, I'm getting errors like
**Error:(4, 37) error: package android.support.design.widget does not exist**
As I never post without it, I've already done plenty of searching on this. Basically, what I've understood is that it couldn't find that Widget Package on my PC. So, do I have to download it? If yes, then how?
People on internet had similar problem with Packages and almost every post has different answer to this. Some say change your Gradle File others say Update your Studio (have done it).
Any kind of explanation or bit of knowledge with the solution would be highly appreciated. I'm a kind of geek who want to get concepts and basics clear. So, it would be great if you include the reason and technicality behind this too with your answer. Thanks. :)
It's a design library for Android apps development and as #Dominique pointed have a look at that page and copy paste that compile 'com.android.support:design:22.2.0' line in your project gradle file and press the sync button. Your project will sync in a few moments and the design library will be downloaded. Now you can use this library and there won't be any errors.
No, in Java "package" is not a "library" or a "piece of software" (like it is in some other languages). Package is what classes belong to - you might think of packages as directories containing Java files (it is a simplification, but it works). In Java libraries are packaged into (usually) "jars" (those jars usually contain classes divided into packages), so what you need to download is "jar".
So, first thing you need to check is: what library contains the package, and configure your IDE accordingly. The package in question belongs, I think to the so called android support library, which you can install using the SDK tool.

How to ProGuard and Optimizer and Obfuscator in Java

I downloaded the eclipse from the google bundle but yet I dont know if it is optimizing the code once it gets compiled. How do I enable optimiziation and obfuscation for my code in eclipse for java or do I need to get a special plugin to do so? I want to make my files as small as they can to be a quicker download for users
If this is a bad question please do not -rep me, just tell me and I'll remove it
I've used ProGuard once or twice, never extensively but my understanding is this: it is an external bundle of files that you must run (either command line or through its GUI) in order to use it. I have used the GUI and it gives you several different tabs for each of the options (Optimizing, Shrinking, and Obfuscation). You can find their project page here with more information and detail on how to use it. As far as I know there is no IDE intergration for ProGuard.

Google App Engine "repackaged" package

What is the purpose of the classes in this package?
I want to use Base64 encoding in my app. As I'm typing away in Eclipse, I am prompted if I want to import a class called "com.google.appengine.repackaged.com.google.common.util.Base64"
I can't find any documentation about what this class does. No javadoc, or no mention in the Google App Engine manual (that I can see). Is this some kind of "hidden" API that I'm not supposed to have access to?
Is this some kind of "hidden" API that I'm not supposed to have access to?
Yes.
The purpose of repackaging Java classes is to have a private copy of a library that otherwise might conflict with another version of that some library (that the application developer adds to his project as a jar file).
It is one possible answer to JAR-hell.
Even the JDK makes use of this mechanism, e.g. with com.sun.org.apache.xerces which is an XML parsing library developed by the Apache Project that Sun choose to include (repackaged).
Do not call these classes directly. (You could, and they would probably work okay, but as they are not part of the official API, they could disappear in the next version).

Categories