Skip to content

Repository files navigation

Reverse Engineering an Android APK (SurviveGame)

Assignment Summary

I received an APK file which I required to perform reverse engineering on the apk’s code in order to reach a state where the application builds and runs successfully.
The game is simple: the goal is to survive and reach your city. At the entrance screen you must enter an ID number, then analysis the code to understand how the game unfolds.


How to Run

  1. Open the project in Android Studio.
  2. Sync Gradle.
  3. Run the app on an emulator or physical device.
  4. Enter an ID number on the entry screen.
  5. Continue the game flow according to the logic discovered in the code.
  6. A Toast is displayed with the resulting city name.

Work Process & Fixes (Detailed)

0) Initial Setup

  • Used an online APK decompiler to extract the project contents.
  • Created a new empty Android Studio project.
  • Copied the Java source files and relevant resource folders (especially layout/) into the new project.

1) Resource File Name Cleanup

Some decompiled resources contained invalid naming patterns for Android builds:

  • Removed $ symbols from file names.
  • Removed trailing underscore (_) from the end of file names where it appeared.

This prevented Gradle/AAPT2 from rejecting resources due to invalid names.

2) Fixing objectAnimator Placement

Some XML files starting with AVD* contained <objectAnimator> elements and were placed in the wrong resource directory.

  • Moved those AVD*.xml files into: res/animator/

This resolved errors like: “Element objectAnimator is not allowed here” (caused by placing animator XML under the wrong folder).

3) Fixing the Illegal char <:> / values.xml Merge Failure

Build error encountered:

  • Illegal char <:> at index 68: ...app-mergeDebugResources...:/values/values.xml

To resolve it, I avoided importing problematic, decompiled “dump” value files and instead:

  • Copied only safe and necessary values resources into res/values/:
    • colors.xml
    • strings.xml
  • Created a themes.xml file to support the manifest theme reference:
    • @style/Theme.SurviveGame

This prevented corrupted/generated values content from breaking the resource merge step.

4) AndroidManifest Fixes (Modern Android Requirements)

I updated the manifest based on Android Studio/AGP warnings and errors, including:

  • Ensuring components that require it (Android 12+) explicitly define:
    • android:exported="true/false" when an intent-filter is present.
  • Adjusting manifest configuration to align with modern Gradle namespace handling.

5) Gradle Build Fixes

Updated the module build configuration according to the IDE/AGP recommendations, including:

  • Proper namespace
  • Appropriate compileSdk / targetSdk / minSdk
  • Dependency alignment (so resources and themes resolve correctly)

6) Removing Decompiled Resource “Dumps”

The decompiled res/ contained many files that were not truly part of the app, but rather artifacts of the decompilation process (library/test dumps).
I deleted these dump resources from various res/ subfolders to prevent:

  • missing-resource references,
  • invalid attribute values,
  • and resource linking failures.

7) UI Adjustment – ID Input Field

To make entering the ID number easier:

  • Increased the EditText width on the entry screen for more comfortable input.

8) Fixing a Corrupted URL in strings.xml

The URL stored in strings.xml contained invisible Unicode characters (not visible in the editor), which caused runtime/logic issues.

  • I replaced it with a clean URL value (retyped/clean-pasted).
  • The final clean paste ID used was: T67TVJG9

9) Understanding Game Logic (Debugging & Code Analysis)

After the app ran successfully on my phone, I debugged the relevant code section and extracted the logic that determines the path/steps.

Direction mapping found in code:

  • Right = 1
  • Up = 2
  • Left = 0
  • Down = 3

Extracted the generated STEPS array according to my personal id number:

  • STEPS = [3, 1, 1, 0, 2, 1, 1, 3, 1]

City selection behavior:

  • The resulting array is influenced by the ID number using a modulo 4 operation per digit (as implemented in the code).
  • In my case, the chosen location was determined by the 8th digit of the ID number, resulting in index 7WASHINGTON.

10) Toast Duration Constants

I fixed constants related to Toast message duration where the units/values were incorrect, so the Toast behaves as expected.

11) Cleaning a Redundant Activity Reference

I removed an explicit path reference to Activity_Game from Activity_Menu because the package already contains the correct path resolution.

12) Build Hygiene During the Entire Process

Throughout the workflow, after major changes (deletions, resource moves, file renames, value edits), I repeatedly executed:

  • Clean Project
  • Rebuild Project

This ensured Gradle and AAPT2 were always working against an up-to-date state.


Final Result

  • The project builds and runs successfully.
  • The Toast city result after “surviving” is:
    • WASHINGTON

made with ❤ by Maor Mordo

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages