How to get ProGuard mapping file of previous release build - android

I have an application in production, I have got some crash report stacktraces and they are from the previous release version. I don't know if I have the ProGuard mapping file for the previous build version. I have the current one. And as far as I know that the mapping file is different for different release builds.
My question is:
How do I get the mapping file for the previous build?

If you created an app bundle (.aab) instead of an app package (.apk), you can extract the mapping file from there.
Download app bundle from Google Play Console
Rename file extension from .aab to .zip
Extract ZIP archive
Navigate to BUNDLE-METADATA/com.android.tools.build.obfuscation/proguard.map
Open proguard.map with file editor, it is the mapping file.

The mapping file is overwritten after every build so you probably lost it for good.
The best approach I can think of would be versioning your code with some VCS (Git, for example) and moving the mapping file to a location that is not being gitignored.
To move the generated proguard mapping file to a different path check this answer. You can even rename it if you like.

Related

The native debug symbols contain an invalid directory symbols. Only Android ABIs are supported

When i'm trying to upload my symbols.zip file on play console this error msg is coming please help me about this "The native debug symbols contain an invalid directory symbols. Only Android ABIs are supported" - unity
enter image description here
By default the debug symbols zip that Unity produces does not conform to what Google Play expect. However its easily rectified as long as you follow these steps accurately.
Step 1: Make A Back Up
Before proceeding make a back up of the original symbols.zip file! You want to keep this around in case you need it in the future. Though in practice I've never found a need for it but its better to be safe. I usually unzip it then use 7-Zip to re-compress it to a much smaller filer.
Step 2: Unzip the Symbols and Fix Them
Unzip the symbols.zip to a separate folder.
Within it you should find one or two folders called 'arm64-v8a' and/or 'armeabi-v7a' depending on if you are supporting older 32bit arm cpus.
For each of those folders;
Open the folder.
Delete the file 'libil2cpp.so.debug'.
Rename the file 'libil2cpp.sym' to 'libil2cpp.so'.
Sometimes the file names are different, in that case
Delete the file 'libil2cpp.dbg.so'
Rename the file 'libil2cpp.sym.so' to 'libil2cpp.so'
Rename the file 'libunity.sym.so' to 'libunity.so'
Step 3: Zip Up Your New Symbols
Select the folders and zip them up.
On Windows you can simply use right-click - send to - compressed ( zipped ) folder, though I use 7-Zip via 'add to archive' using the zip format with a high compression level.
IMPORTANT
You must ensure that the zip directory structure matches that of the original Unity generated symbols.zip. Which is that both folders are 'loose' in the zip file, they are NOT children of a parent folder!
For example instead of having a zip of
MyApp-1.0.2-v2.symbols / arm64-v8a / libil2cpp.sym.so
you might end up with
MyApp-1.0.2-v2.symbols/MyApp-1.0.2-v2.symbols / arm64-v8a / libil2cpp.sym.so
Step 4: Rename Your Newly Zipped File
Rename the newly zipped file to match the name of the original Unity generated symbols.zip file.
Step 5: Upload Your New Symbols.zip
You should be able to upload the symbols.zip to the Play Console without error.
If you do get an error, double check the zip against the original one from Unity. Make sure the filenames match exactly and ensure the directory structures match!
If you still have an error you may need to rename 'libunity.sym.so' to 'libunity.so' in both folders too - though there are conflicting reports on that and I've never had to.
It should be noted that Unity's default compression settings for the zip are poor, generating very large files with poor compression. When you re-zip the symbols after following the steps above it should be much smaller. For example I frequently get 1GB debug.symbol.zips from Unity, but end up with only about 150MB zip file after performing the steps above.
What worked for me (Unity 2020.3.3f1) was the following:
Unzip symbols
Rename libunity.sym.so to libunity.so in both folders (arm64-v8a and armeabi-v7a)
Now both folders contain the following files:
libil2cpp.dbg.so
libil2cpp.sym.so
libunity.so
Zip everything in a way that preserves the original file structure and use the same name as before unzipping
Upload
For the renaming I used the bash file provided in this post.
I solved it.
I uploaded only the armeabi-v7a folder.
Please try again.
filename : libil2cpp.so, libunity.so

File 'root/lib/META-INF/MANIFEST.MF' uses reserved file or directory name 'lib'

I tried to apply for app bundle but I failed.
I can build apk with spilit option but I couldn't make aab.
I put the following gradle option.
bundle {
abi {
enableSplit = true
}
}
The error message in the console is below.
File 'root/lib/META-INF/MANIFEST.MF' uses reserved file or directory name 'lib'.
The file structure that was built is like below.
I heard I have to add the below library, but I didn't.
Actually, there is no difference either I add the play core library or not.
implementation "com.google.android.play:core:$play_version"
I wanna change some options to avoid alias problem but I don't have any idea about that.
Anyone who can handle this problem simply?
Make sure you don't have a directory called "lib/" in your project, since this directory name is reserved in the APK format for storing native libraries.
If not in your project, one your library dependencies must have it and is being copied into the APK.
The reason it works for APKs but not AABs is that the AAB format is more strict and will prevent you from embedding unnecessary files in your app.

Gradle build failing due to keystore.properties file missing

I'm trying to use this alarm app on Android Studio - https://github.com/philliphsu/ClockPlus . However, gradle build is failing (error message below). Please let me know what needs to be fixed for this to work.
Error:/Users/***/Documents/Apps/ClockPlus-master/keystore.properties (No such file or directory). Let me know what exactly is this keystore.properties and is it possible to create this file as it's not available in the github repo files.
what exactly is this keystore.properties?
When you want to publish your app in the google play, you need to sign your app. When you create a signing configuration,Android Studio ,by default, adds your signing information in plain text to the module's build.gradle files. If you are working with a team or open-sourcing your code, you should move this sensitive information out of the build files so it is not easily accessible to others. To do this, you should create a separate properties file to store secure information and refer to that file in your build files. That file is the keystore properties file.
Read more about this
Is it possible to create this file as it's not available in the github
repo files?
Create a file named keystore.properties in the root directory of your project. This file should contain your signing information, as follows:
storePassword=myStorePassword
keyPassword=mykeyPassword
keyAlias=myKeyAlias
storeFile=myStoreFileLocation
If you do not have store password, key password etc. you should sign your app.
Read more about this
The whole information about this is in the Android Developer documentation, in the link I provided above.

How to obfuscate an APK in Android 2.1/2.2

We know in SDK 2.3 we can obfuscate APK with Proguard.
The question is: How to obfuscate APK in Andorid 2.1/2.2 SDK?
Edit the file (in the project root) project.propierties and add the line
proguard.config=proguard.cfg
And its done. When you try to generate the signed apk of your app it will take a little longer and it will be obfuscated.
If you receive the "Conversion to dalvik error" when generating the apk you need to update the proguard of your sdk. For doing it you need to go to the ProGuard page to the download section. Download the last stable version and put it content in
SDK_ROOT/tools/proguard
Deleting the existing content before of course.
You can check the Proguard manual at their page (link is above) and the Android's Proguard page for more info about ProGuard
if you want to verify if the code was obfuscated do this:
download:
1.
dex translator tool - http://code.google.com/p/dex2jar/
then this tool to view the classes:
JDGUI- http://java.decompiler.free.fr/?q=jdgui
2.
after you install dex2jar unzip it etc and remember the folder its in.
open up the apk file using winzip or winrar. You'll see a file there called classes.dex
copy that file into the same folder that dex2jar is in (the dex translator tool you just downloaded).
3.
In the same folder click on setclasspath.bat
Open up a command prompt and traverse to the same folder that dex translator is in and run:
dex2jar classes.dex
-another file shows up now. Open up JDGUI and open up the file that got generated its called classes_dex2jar.jar ....
4.
you can observe if the decompiled code is obfuscated(readable) now.

Android - add files into APK package?

is it possible to add to my apk file some XML file storing program version, update path and other useful data (note: I don't mean Android XML file). All I want to is this file to be unpacked somewhere to local data folder and I will use it for comparing version info installed locally and on the server in case of updates.
I am asking - is it possible to add to apk some other file?
Thanks
The assets/ folder in apk is intended to store any extra user files in any formats. They will be included to apk automatically on compilation stage and can be accessed from the app using getAssets() function. For example:
final InputStream is = getResources().getAssets().open("some_file.xml")
It is even unnecessary to copy them to some local folder to read them.
If you only want to know the version info of the app then there is a much easier way to identify it. You can use
getPackageManager().getPackageInfo(getPackageName(),PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionCode
to get the version code and
getPackageManager().getPackageInfo(getPackageName(),PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionName
to get app's version name

Categories

Resources