APK file is generating without "src" code - android

When I try to generate an apk file from android studio "src" code in there in apk file. I opened apk using "winrar" but, there is no src folder in it.
What is happening?

Your source code is converted into dex file. You will file .dex file in the extracted folder.
When you build APK in the android studio. It converts your source code into java ByteCode(.class file) and then again process all class file into single/multiple Dex file(.dex) based on method count.
Check this image for more information:
Image Reference link.

The src folder is your source code.
No Java or Android application actually runs your source code, rather all Java files are compiled to class files and relocated to the classpath of a JAR, or APK or AAR for Android. Typically there are folders for each package, then class files under that

Related

How to add .java files to .apk archive within gradle

How to add .java source files of android project to .apk using gradle? Suppose you have been given this android kotlin app sample. How to extend build.gradle.kts to include .java files from ./app/src/main/java/org/gradle/samples/ to the .apk archive during build process? The target should be the root directory of .apk archive.
I've read several posts, such as this and this. But I haven't been able to complete the task yet.

How to get android.mk file from decompiled APK?

I have an .apk I decompiled and I see there are **.so** files used in that code.
How do I find the **.mk** file from that source code?
You can't.
Build scripts like build.gradle and the .mk, if there even was one, are used to build the .apk but are not included in the output of the build i.e., the packaged .apk

How to add a folder to a android apk use appt and ant

When I use ant tool for build an android project, I do not know how to add custom folders to the apk file, such as a a folder named "running" under the project root, when I use the eclipse can be directly add to apk. I hope you can give me some help, thanks!
During the build process, your Android projects are compiled and packaged into an .apk file, the container for your application binary. It contains all of the information necessary to run your application on a device or emulator, such as compiled .dex files (.class files converted to Dalvik byte code), a binary version of the AndroidManifest.xml file, compiled resources (resources.arsc) and uncompiled resource files for your application.
I can't figure out why you need to add the folder to apk, well if you are asking about adding it in the project and later to be accessed in the apk then yes you can place it inside the "assets" folder of your project

How to see the source code of an application in android

Is there any way to see the souce code of an application from the app. i tried this method by using the apk ectractor to extract the apk file from an application but i cant find any src file when i convert the apk file to zip. there only the res file which has all the xml files. i need the src file which has all the java file in it to see how the application work.
you can do the following reverse engineering processes
using apktool decompile your apk file to
using dex2jar convert dex into normal Java jar files.
now you can do any of two
a. use JD-GUI to decode the jar to java source. or
b. extract the jar using 7zip to class files and then use cavaj to decode to java files
There must be other tool which you can find by search
useful links: see this
Depending of the apk/zip it can contain java classes, or a .dex file.
if it contains the .dex file, first you need to extract the clases from it (search online for a dex class extractor) and then when you get the actual java clases, you'll also need a java decompiler to be able to get to the source code from these classes.

Exporting Android Library project with resource folder images

I am new to Android. I am using the reusable code, so I convert that to JAR file. I am using images from JAR source res folder. I have accessed those images by "R.drawable.imagename" in library source. While I am converting the library source to JAR, I have export those res folder. If I am using the JAR in another android application, that will be crashed. I have followed the link below to convert the library source to JAR.
"http://www.cs.utexas.edu/~scottm/cs307/handouts/Eclipse%20Help/jarInEclipse.htm".
Where I am doing things wrong.? Is there any another procedure to convert the android library project to JAR with resources.? or Is there any wrong in accessing the res folder image in android library source.?
Please help.
UPDATE:
The new Gradle based build system supports "aar" files which , apart from compiled code, can contain resources etc as well.
OLD:
Resource packaging in library projects is not supported by android build tools. You will have to provide a separate zip for res folder along with the jar file.
Code goes in jar (for library) or dex (for app). Resources are separately bundled into apk file. Hence the SDK resource packager tool works only when you are exporting an apk file.
Yes, a jar file can contain resources, but, dependent android project's won't look up in jar file for resources.

Categories

Resources