Im not sure what it is called but ill do my best to explain it. I did search here on stack exchange and found this answer for an allias for path but i dont want to set a variable for it and i already know that. create alias for path
What I need is and its been along time since I seen it but its used with a % or $ or something that when the program runs from the directory it knows where the directory for the game files are. It didn't matter what the directory the program is in as long as the directory 'gameFiles' is in that directory it will work.
Here's my path:
"/storage/emulated/0/MyGame/MyHackGame/jni/gameFiles/oscom.txt"
I think its something like:
"%or$/gameFiles/oscom.txt"
The main problem is I have a project on source forge and don't want my developers to have to change these paths like 100 times to run the program and then I'll have to change them back.
Also iam using aide for android to make the program and using the standard c++ libaray do this might be difficult to do. I'm not even sure if I can add libarays with aide and native code or how to do it.
Use symlinks as Eugene has suggested or modify build scripts to generate user specific paths into binaries or spearate files at build time. These are ignored by version tracking, so no more double mills. Another way might be checking env variables at runtime.
Related
A third party created a unity project for me but they lost their project on their end. A guy had it on his laptop, never backed it up but he did send the integrated unity project for android. The only issue is that we need to change something inside it. So I have the android project, I just need the built unity's source code.
The same situation occurred with our IOS version, luckily Xcode had the Assembly-Csharp accessible and I could find the value I needed to change. The Android's Unity was built with il2cpp. I've managed to re-secure the assets using some tools I've found online. So I can potentially rebuild the project with new scripts. However this may take a rather large amount of time. So I found I can edit the source code through the hex code, but this seems limited/nigh impossible as I need to make a condition on this string instead of simply setting the value. If there is a way to do this with a hex editor on the lib2cpp.so file I would greatly appreciate even a lead. Alternatively I have found some things on hooking a string, but I am unsure of how to go about this and cannot find sources of where to start such a thing.
Any leads or information on how to edit a string on a condition in the unity source code through it's lib2cpp.so file or libunity.so file would be greatly appreciated!
I have my own developed Android app in kotlin. I lost my all source code (hard disk crashed) after that I pull my apk from my physical android device using below adb commands -
c:\> adb shell pm path com.digi
Response of this command is full path of apk. after that I used below command to get actual apk-
c:\>adb pull /data/app/com.digi-ZF6WfmctELhsLvm4oICrAQ==/base.apk Destination\folder
After that I used android studio and using build -> analyze APK
This is giving some folder structure but did not get any kotlin class what I developed.
Is there any way to get at least kotlin source code?
Well, yes and no. You can't recover your source code fully, but you can at least get some of it. It will be partially gibberish and partially almost fine, you'll lose local variable names, comments, formatting, etc., so you will need to go through all files and fix them or even rewrite some of them entirely. But still it could be better than starting from scratch.
I did not decompile Android apps for a long time, so my knowledge may be outdated, but the standard procedure is:
Convert the code from dex to jar.
Decompile to Java.
In your case: convert Java to Kotlin.
Ad.1.
AFAIK there are two tools to do this: dex2jar and enjarify. I suggest using enjarify, it always gave me better results.
Ad.2.
There are several Java decompilers and some of them will work better with some code, others will work better with another. I suggest trying at least Fernflower and JD-CORE/JD-GUI, maybe Krakatau.
I guess the results will be far from perfect, because the application is written in Kotlin, not in Java. Suspend functions and other features specific to Kotlin will be even worse.
You can also use ByteCodeViewer which is a GUI applications that simplifies the process of 1. and 2. It contains all above tools and more. You can also switch the decompiler dynamically to see results of different ones.
Ad.3.
IntelliJ has some utils for converting Java to Kotlin. I never tried this with decompiled code and I guess it will be problematic
If you would need to recover the resources (XML files, etc.), you can try to use apktool.
Is it possible to debug an app on many phones at the same time in Android Studio? By this I mean launching multiple debug instances, each one on a different phone, like in Eclipse.
At the time of posting this question probably the only solution was the one posted by George V.M. Now, after several updates of Android Studio, this can be easily done by creating N copies of the same Debug configuration and launching each of them on a separate phone.
Update
You might want to take a look at Vlad's answer. This one is pointless for newer versions of Android Studio. In case anyone is still curious, this was my really hacky way of solving the problem
In case anyone out there is still looking for a solution to this, here's what I've found.
I'm working on a project that requires wireless communication between 2 instances of the same app running on 2 phones (actually, 2 or more). There were a lot of times where I wished I could debug 2 devices at a time. It wasn't until recently that I figured out how to do it.
It's actually quite simple: Have 2 instances of Android Studio open and you can debug multiple devices at once, (one device on each Android Studio instance) with breakpoints and everything!
Catch 1: You can't open two instances of the same project
I haven't been able to run two instances of Android Studio where both instances have the same project open. It will just redirect you to the already open project.
Solution:
The solution to this is to just make a copy of your project somewhere on your PC and open that project allowing you to have two copies of the same project open.
Catch 2: Changes have to be made on each copy manually.
Now here's a new problem. What if while debugging, you find a mistake in your code and amend it. Now you have to make sure you make that exact same amendment in your second copy of the project so that the second device doesn't have the same error if it hits those lines. This is annoying, having to remember to make a change twice; once in each copy of the project.
Solution:
My solution to this problem was to just make a 'symbolic link' of the project instead of a physical copy.
(A symbolic link is a 'nickname' or a 'reference' to a file. If you make a symbolic link fileB that points to fileA, although they seem like two distinct files to the OS, they in fact point to the exact same physical file. Any changes made on fileA will be reflected in fileB since they point to the same physical file/data on the disk. Instructions on how to create symbolic links are given below)
Now hold on just one second!!! Making a symbolic link of the entire project might not be a very smart idea since you'll have two Android Studios trying to edit the same files. This could lead to problems, especially in the case of build files and IDE files.
So what I did was make a symbolic link of only the source files, or any file which I'd be editing directly and which AS wouldn't normally touch, and make a physical copy of every other file.
The only thing you need to do is remember to hit Ctrl+S after making changes to your code in one AS instance so that the changes will be reflected on the second one. It might still take a couple of seconds for those changes to be reflected in the second instance but you can just click the "Synchronize" button (top left, next to "Open" and "Save") on your second AS which will cause all externally changed files, i.e., the file you just edited in your first instance, to be reloaded from disk.
You still need to be careful though. Every time you make a change in one AS, make sure you save all those changes and that those changes are reflected in the second AS before you try doing any editing in the second AS. Otherwise conflicts could cause you to lose the changes you made in one copy. One way around this is to force yourself to make changes to a file only on one AS and not the other.
Actual Instructions:
Okay that was a lot of talk. Here are the steps you can follow along with tips:
Close Android Studio and make a copy of your project into another folder on your PC
Go to your second copy and delete all your source code files since we're going to make symbolic links of them.
(these are the files I usually make symbolic links of instead of a copy:
all build.gradle files
the entire app/src folder
if you have any other loose source or resource files or othwerwise non IDE files that you might edit, make symbolic links of them as well
Make a symbolic link of all those non IDE files from the first project folder into your second project folder.
to make a symbolic link of a file in Windows, use
mklink path\to\symbolic\link path\to\original\file
to make symbolic link of a folder in Windows, use
mklink /j "path\to\symbolic\link" "path\to\original\folder"
to make a symbolic link of a file or folder in Linux, use
ln -s "path/to/original/file_or_folder" "path/to/link"
Open up Android Studio again. It will probably open the original copy of your project if that was the last project you opened in AS.
Go to File>Open and open up the second project copy on your PC.
You will now have 2 copies of your project running and you will be able to debug your app on 2 devices at the same time! (Remember that breakpoints won't be shared between the two copies)
If you are talking about attaching the debugger to several phones, I'm going to say no.
The port will be blocked with that traffic from one phone.
Unless someone figure out a hacky way to do this, atm It's not possible as far as my knowledge.
Android studio has its VM devices, but it requires installing Intel Accelerator because it's too slow until it show up. alternatively, I recommended "Genymotion" for running multiple instances and different devices. I'm using it and its working perfectly.
It may takes a while for setup and installing but once its installed it will be light weight and I promise you'll be pleased while working on it =)
Here is the link:
genymotion intallation user guide,
genymotion website
How can I get reach to the native methods called from Java side in Android? My problem is specifically related to AudioRecord class in Android Media package. I read the source code of AudioRecord.java. I found out that most of the jobs is performed by native methods, such as:
native_setup(...), native_start(...), native_stop(...), native_read_in_byte_array(...), native_read_in_direct_buffer(...)
I downloaded Android source code but I could not reach these methods. And I don't actually know the way to reach them. I seek for these methods in libraries I found in source code directories, but I couldn't success. If anybody may have an idea, I would be appreciative to hear. Thanks...
I think I found them. After using the Linux command
grep -r "native_read_in_direct_buffer" ./ANDROID_SOURCE/.*
I found the corresponding cpp files.
AudioRecord.cpp is located in: ~/ANDROID_SOURCE/frameworks/av/media/libmedia/ directory,
android_media_AudioRecord.cpp is located in ~/ANDROID_SOURCE/frameworks/base/core/jni directory.
I wanted to share it as a reference to other possible programmers willing to reach the same/similar source files.
This question is related to this other one. I have recompiled Android framework and generated a new image. I need to add some classes to the original framework and did it by adding new jars that go into /system/framework. I modified BOOTCLASSPATH to take into account these new jars.
Building the image and flashing to the device does not work. Some optimizations must be run prior to that, but I do not know how that process is.
What building steps should I execute before generating the image or what other alternatives do I have so the extended framework classes are accesible from applications?
I also changed the bootclasspath by changing one of the .mk files, adding my jar to a line that looks like this:
PRODUCT_BOOT_JARS += myjar
Then you just have to make the build and flash to the device just like what you said.
Sometimes it might not be enough and you'd have to erase this file:
./obj/ETC/init.environ.rc_intermediates/init.environ.rc
and then make again.
Hope that helps.