Skip to content

Commit cf9cd23

Browse files
Added option for generating a Gradle based Android project
1 parent 74c090d commit cf9cd23

8 files changed

Lines changed: 121 additions & 3 deletions

File tree

decompileAPK.sh

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,34 @@ rm -Rf $DOE/output-res
6666
rm -Rf $outputDir
6767
mkdir -p $outputDir
6868

69+
# Generate directories for project structure
70+
if [[ "$generateProject" == true ]];
71+
then
72+
moduleName=app
73+
74+
mkdir -p $outputDir/gradle
75+
mkdir -p $outputDir/gradle/wrapper
76+
mkdir -p $outputDir/$moduleName
77+
mkdir -p $outputDir/$moduleName/libs
78+
mkdir -p $outputDir/$moduleName/src
79+
mkdir -p $outputDir/$moduleName/src/main
80+
mkdir -p $outputDir/$moduleName/src/main/java
81+
82+
baseOutputDir="$outputDir"
83+
resOutputDir="$outputDir/$moduleName/src/main/res-output"
84+
outputDir="$outputDir/$moduleName/src/main/java"
85+
fi
86+
6987
# Create JAR from APK file, then decompile that JAR to have Java files
7088
echo "Extracting JAR file from APK"
7189
sh $DOE/dex2jar/d2j-dex2jar.sh -o $outputDir/output.jar $apkfile
7290
echo "Decompiling JAR for Java files"
73-
java -jar $DOE/jd-core-java/jd-core-java-1.2.jar $outputDir/output.jar $outputDir/src
91+
if [[ "$generateProject" == true ]];
92+
then
93+
java -jar $DOE/jd-core-java/jd-core-java-1.2.jar $outputDir/output.jar $outputDir
94+
else
95+
java -jar $DOE/jd-core-java/jd-core-java-1.2.jar $outputDir/output.jar $outputDir/src
96+
fi
7497
rm $outputDir/output.jar
7598

7699
# Extract all resources from the APK and remove all the unnecessary files from the output
@@ -79,8 +102,21 @@ java -jar $DOE/apktool/apktool.jar decode -f $apkfile $resOutputDir
79102
rm -Rf $resOutputDir/smali
80103
rm $resOutputDir/apktool.yml
81104

82-
# Move the resource-output to output directory
83-
mv $resOutputDir/* $outputDir
105+
if [[ "$generateProject" == true ]];
106+
then
107+
# Move the resource-output to correct project directory
108+
mv $resOutputDir/* $baseOutputDir/$moduleName/src/main/
109+
else
110+
# Move the resource-output to output directory
111+
mv $resOutputDir/* $outputDir
112+
fi
84113
rm -Rf $resOutputDir
85114

115+
if [[ "$generateProject" == true ]];
116+
then
117+
cp $DOE/files/project/* $baseOutputDir/
118+
cp $DOE/files/wrapper/* $baseOutputDir/gradle/wrapper
119+
cp $DOE/files/module/* $baseOutputDir/$moduleName
120+
fi
121+
86122
exit;

files/module/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 20
5+
buildToolsVersion "20.0.0"
6+
7+
defaultConfig {
8+
minSdkVersion 19
9+
targetSdkVersion 20
10+
}
11+
buildTypes {
12+
release {
13+
runProguard false
14+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
15+
}
16+
}
17+
}
18+
19+
dependencies {
20+
compile fileTree(dir: 'libs', include: ['*.jar'])
21+
}

files/module/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/vrancdi/Documents/APPS/android-sdk-bundle/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}

files/project/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:0.12.2'
9+
10+
// NOTE: Do not place your application dependencies here; they belong
11+
// in the individual module build.gradle files
12+
}
13+
}
14+
15+
allprojects {
16+
repositories {
17+
jcenter()
18+
}
19+
}

files/project/gradle.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Project-wide Gradle settings.
2+
3+
# IDE (e.g. Android Studio) users:
4+
# Settings specified in this file will override any Gradle settings
5+
# configured through the IDE.
6+
7+
# For more details on how to configure your build environment visit
8+
# http://www.gradle.org/docs/current/userguide/build_environment.html
9+
10+
# Specifies the JVM arguments used for the daemon process.
11+
# The setting is particularly useful for tweaking memory settings.
12+
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14+
15+
# When configured, Gradle will run in incubating parallel mode.
16+
# This option should only be used with decoupled projects. More details, visit
17+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18+
# org.gradle.parallel=true

files/project/settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ':app'

files/wrapper/gradle-wrapper.jar

48.7 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Apr 10 15:27:10 PDT 2013
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

0 commit comments

Comments
 (0)