I imported a project from eclipse and now I want to add its proguard-rules.txt files. This is how the app structure looks like:
I saw other places where build.gradle files were located differently, how can I do it?
Where and how can I add the proguard-rules.txt file?
How can I make sure that proguard is actually affecting the APK (in eclipse it generated several txt files)?
Did you look at: File -> Project Structure -> (module_name) under Modules -> Flavors -> Proguard File in Android Studio?
See in "projectfolder"/module_name/proguard-rules.txt
In your case "projectfolder"/app/proguard-rules.txt
At the same time it is not created automatically. You can create it manually.
Related
I have a project with multiple Android modules and I would like to overwrite their gradle file. How can I accomplish that?
I am using the "mainTemplate.gradle" file for the main Android project and it works fine, but if I put this template inside my module, it's not used when building to Android project.
You can only put mainTemplate.gradle in your <ProjectName>Assets\Plugins\Android folder as this is where Unity hard-coded a way to look for the gradle file. If you put it anywhere else, it won't work since Unity can't find it. There are stuff you can't do inside Unity Editor and this is one of them.
The solution is to export your project and build it with Android Studio. By doing that, you can add as many gradle file as you want in your exported Android project.
I am studying the file/directory structure of an Android Studio project.
I don't understand the purpose of two files in /app directory:
app.iml
proguard-rules.pro
May I have some explanation on these files? If I want to share my project with other programmers, then do I have to include these files or just whatever that goes under /src plus build.gradle is enough?
May I have some explanation on these files?
app.iml is an Android Studio-generated file, based on the contents of your build.gradle files, that is used internally by the IDE. Android Studio is based on IntelliJ IDEA; .iml files are IDEA's project metadata files. Android Studio does not consider them to be the system of record — the build.gradle files are — but presumably it was simpler to generate .iml files rather than rework IDEA to not need them.
proguard-rules.pro contains module-specific rules for configuring code obfuscation and shrinking. Presently, that is handled through a tool named ProGuard, which is why the file is named as it is.
If I want to share my project with other programmers, then do I have to include these files or just whatever that goes under /src plus build.gradle is enough?
app.iml is output; it isn't in build/ for technical reasons, I presume. You should not distribute this.
proguard-rules.pro is input. You should distribute this, even if it is largely empty at the moment.
app.iml is a file generated by Android Studio holding information about your project
It is the usual file format for IntelliJ.
proguard-rules.pro is used, if you enable proguard (minifyEnabled true) in your build.gradle file. It helps improving performance and keeping your app small.
To read more about proguard, read here:
http://developer.android.com/tools/help/proguard.html
From intelliJ documentation what I understand is you SHOULD share the iml files to for smooth collaboration with other developers who use android studio, I'm pasting the following text from their documentation, link here https://intellij-support.jetbrains.com/hc/en-us/articles/206827587-How-to-manage-projects-under-Version-Control-Systems
If you decide to share IDE project files with other developers, follow these guidelines:
Directory based project format (.idea directory)
This format is used by all the recent IDE versions by default. Here is what you need to share:
All the files under .idea directory in the project root except the workspace.xml and tasks.xml files which store user specific settings.
All the .iml module files that can be located in different module directories (applies to IntelliJ IDEA)
Be careful about sharing the following:
Android artifacts that produce a signed build (will contain keystore passwords)
In IDEA 13 and earlier dataSources.ids, datasources.xml can contain database passwords. IDEA 14 solves this problem.
You may consider not to share the following:
gradle.xml file
user dictionaries folder (to avoid conflicts if other developer has the same name)
XML files under .idea/libraries in case they are generated from Gradle project
Legacy project format (.ipr/.iml/.iws files)
Share the project .ipr file and all the .iml module files, don't share the .iws file as it stores user specific settings
Android studio will generate a .gitignore with the following values if you integrate git version control integration with the IDE
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
In my demo project, proguard-rules.txt is not available in Android studio.
I must be missing some code :
Where can I find proguard-rules.txt file?
I want to add proguard rules
Any help is appriciated
Thank you
Looks like your project is missing proguard files. You can add it yourself: put the proguard-rules.txt file into the app directory. It's already added to your build.gradle file so no further actions required.
proguard-rules.txt (or proguard-android.txt) are in your SDK folder, but if you want to add something to your ProGuard rules you should do this in proguard-rules.pro.
This file should be automatically added to your project by Android Studio when you create new (if isn't present - create manually). Check DOC (Gradle section ofc)
it is located under your sdk folder, usually in yoursdk/tools/proguard/. If you are using linux or mac, once you cd into the sdk folder you can run
find . -iname proguard-rules.txt
to look for it
You can manually create the file in the \StudioProjects\your_project\app folder and you can add the custom rules.
I want to minimize the size of .apk file, so I follow the Android Developer guide (http://developer.android.com/tools/help/proguard.html), but there are some problems I encountered as follows:
I create a new project via Android Studio, but it doesn't generate a proguard.cfg file. And there exists a local. Properties file rather than project. Properties file.
How can I figure out this issue?
In the new version of the ADT, the file generated is not proguard.cfg but proguard-project.txt. Proguard must be activated in the file project.properties.
You can check this link: http://tools.android.com/recent/proguardimprovements
Hi I developed one small library in Java for my Android application. I want to do obfuscating for that library. I using Android version 4.1.2. First thing is that according to Google's Android documentation there is no proguard.cfg file in my project root directory. Instead of that proguard-project.txt is there. I add proguard.config=proguard-project.txt into my project-properties file.
After this configuration I tried to export this library project and try to do obfuscating of that project. It showing error can generate .apk file because it is library project.
Then I tried with another option in export. Instead of regular export android application I use general -> archive file and tried to export it and generate jar file but I check inside the jar and no encoding is done. That means anyone can extract and check classes and content inside my library. But the main thing is that it generates proguard folder inside my project and also generate dump mapping seeds usage.text files inside it.
So I need help to do proper ProGuard obfuscating of my Android library. Am I doing something wrong. What kind of configuration do I have to add inside my proguard-project.txt so that it will do proper encoding of my code?
Actually, you can obfuscate a library project, but not directly! You can only do that by exporting the entire application's project that uses that library.
With that in mind, you can set a different proguard.cfg at the root folder of your Library Project.
Hope this helps.