Reformating code creates a new build - android

I often modify spaces, statement alignments and tabulations manually instead of using CTRL+ALT+L for formating my code. Then, it takes a long time to launch my app because Android Studio creating a new build even if the code itself is the same.
Is there a way to change this setting ?

Android Studio compiles any file when it changes. Even if the change is just in formatting, it will be recompiled. I suggest that you make sure the formatting is the way you want it when you write the code to begin with. Android Studio is very good at helping you with this by automatically indenting when it deems it appropriate. Don't fight against Android Studio's default behaviors -- or else configure Android Studio to the formatting settings you wish to use.

Related

Android studio custom language support

I have the need to add the support for a DSL(domain-specific language) to the android studio. What I want to achieve is an extension recognized and syntax highlighting and at the moment of the creation of the new project set up the necessary files for the environment.
Looking around the web I haven't found a good way to do this. I have thought about some solutions but I can't figure out if these are realizable.
Solution 1:
Modify the standard Android project wizard maybe adding a checkbox that set up the environment for the type of language like the image below.
https://imgur.com/HiIqlsI
I think this is probably unachievable.
Solution 2:
Once I created my default Android project add in the right mouse button click menu an option to set up the environment for the project.
Solution 3:
Create a custom wizard project setup just for my language.
I don't know if it's possible to do a similar thing in Android Studio. Any help is appreciated

How can I check and verify code before committing in Android Studio?

In Android Studio, I check the code by Analyze->Inspect code before committing the code. That is so weird and time-consuming to check it every day and also to check it for different computers. What I want is, I set lint configuration and it will check it automatically while committing the code. Do anyone has configured their Android Studio in this way? How can I do it? Is there any plugin for that? I want to do it because I have read good code quality is equal to good handwriting.
How are you committing your changes? If you use the Commit Changes from the VCS menu (or equivalent keystroke) then there is a whole load of options you can select to be done before the commit, including reformat code, optimize imports, and perform code analysis.

Android studio reformat code multiple formatting issue

I'm encountering problem with Android studio formatting and the use case is:
Using Android studio 1.5.1 with my custom code style defined. Right click on a package and "Reformat code...", Check only on "Include subdirectories" and click Run. It gives me one-line changes in three classes. After that, if I repeat the same procedure, I get more changes in these three classes. After that, if I repeat the same procedure, I get even more formatting changes (using Github for Windows to see the changes).
How is that possible? Is someone experiencing the same problem?

Can we change Android source code using Android NDK..?

I am having a requirement like to add a custom setting to android native settings(like when we go to Home->settings->Display we have Screen timeout,Animation,Auto-rotate screen,Brightness settings available.But i want to add one more setting like auto-screentimeout there.i,e i need to change the source code of android..some thing related to forked android consept)so,Is this possible..?if so can we use NDK for this...
Thanks in advance...
You can download the Android source code and then create your own settings APK. However it will probably only run on the phone you are testing it, and I assume you run into problems when using different Android versions or some modifications by device manufacturers.
Read more http://source.android.com/ on how to get started.
Alternatively you could extract the settings APK from your current phone, decompile it with apktools, and then re-create it again with your changes.
Read more on http://code.google.com/p/android-apktool/
In both ways you need to have root access to install the new APK... and probably a custom recovery to restore from a nandroid backup when your modification crashes!
The Android NDK is for writing application code in C or C++.
What you want is to build your own version of the Android firmware; it is a completely separate issue. Have a look at this for starters.

How to have different versions of an android project on the device?

I need to have different versions of my code on my device when I'm developing my android application. I want to have a copy of my latest code once in a week or so. The reason is that sometimes you make changes to the code and make it worse for a while, then after that you polish your code to include the features. So I need to have a copy of latest correctly running version of my code on the device.
I tried to change the app name, to see whether the ide deploys a new copy of my code, but it didn't work and the ide seems to be smarter than that and it replaces the app with the new name. I suspect that I need to change the package which is a little bit frustrating/risky. Anyone knows the solution?
Right now, I'm using Intellij to implement my android project but I think this doesn't matter.
You need to change the package name.
I use ant build script to do this easily. I created an ant task to rename the package name and make a build.
Typically I use svn to keep track of changes and label which ones are the ones that work then add features and use svn merge commands to combine new features with working code. Then if you want to undo something you can just roll back a revision.
The way I achieved that goal is:
- configure the original project as library
- create another project specifying a different package name in the manifest
- you also need to declare all the activities, receivers, etc with the full name in the new manifest
In that way switching the code of the original project through different branches you can create different apks and have different version of the app installed at the same on your device.
You need to change the package name, not the app name, it's pretty easy in Eclipse.
If your package name now is 'com.sina.perch', so just rename it to 'com.sina.perch1' or something else whatever in file 'AndroidManifest.xml' , which looks like:
It will be work.

Categories

Resources