How to inject FlowUp inside your apk
Decompile flowup sample app
apktool d flowup.apk -o flowup
Decompile your apk
apktool d original.apk -o injected
Copy all the smali
files from the flowup library to your decompiled project
cp -r flowup/smali injected/smali_classes{N}
where N is the next smali_classes
group number
Open your app AndroidManifest.xml
and look for the application
tag to get its android:name
value
Open your app main application .smali
file
Find your application onCreate
method and add the following right after your prologue
section
const/4 v2, 0x1
invoke-static {p0}, Lio/flowup/FlowUp$Builder;->with(Landroid/app/Application;)Lio/flowup/FlowUp$Builder;
move-result-object v0
const-string v1, "YOUR API KEY HERE"
invoke-virtual {v0, v1}, Lio/flowup/FlowUp$Builder;->apiKey(Ljava/lang/String;)Lio/flowup/FlowUp$Builder;
move-result-object v0
invoke-virtual {v0, v2}, Lio/flowup/FlowUp$Builder;->forceReports(Z)Lio/flowup/FlowUp$Builder;
move-result-object v0
invoke-virtual {v0, v2}, Lio/flowup/FlowUp$Builder;->logEnabled(Z)Lio/flowup/FlowUp$Builder;
move-result-object v0
invoke-virtual {v0}, Lio/flowup/FlowUp$Builder;->start()V
Include the following in the injected apk manifest:
<service
android:enabled="true"
android:exported="true"
android:name="io.flowup.reporter.android.WiFiSyncService"
android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
<intent-filter>
<action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
</intent-filter>
</service>
<service
android:enabled="true"
android:exported="true"
android:name="io.flowup.config.android.ConfigSyncService"
android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
<intent-filter>
<action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
</intent-filter>
</service>
<service
android:enabled="true"
android:exported="true"
android:name="io.flowup.reporter.android.DeleteOldReportsService"
android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
<intent-filter>
<action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
</intent-filter>
</service>
Recompile your project
apktool b injected -o injected.apk
Keep in mind we are using apktool v2.2.2
Create a private key, it will ask you for some information you can leave blank and a password
keytool -genkey -v -keystore my-release-key.keystore -alias some_alias -keyalg RSA -keysize 2048 -validity 10000
Sign your app
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore injected.apk some_alias
Install the app and try it out
If the app crashes it is most likely because FlowUp and the application are using different versions of the same library. Try renaming the library package inside the FlowUp code and all its usages within FlowUp. For example, if there is a problem with gson
, rename the directory from com/google/gson/
to com/google/flowupgson/
, then you will have to replace all occurrences in that directory of the string Lcom/google/gson
with Lcom/google/flowupgson
. Repeat the process with all occurrences in io/flowup
.