145

Is there any way I can view the total lines of code in each java class in my project?

Looking for something like this for Android Studio.

Zoe - Save the data dump
28.4k22 gold badges130 silver badges163 bronze badges
asked Aug 26, 2014 at 15:57
0

5 Answers 5

296

Go to https://plugins.jetbrains.com/idea/plugin/4509-statistic and install the latest version

To install

  1. Run Android Studio

  2. From the menu bar, select File-->Settings

  3. Under IDE Settings, click Plugins, and then click Install plugin from disk

  4. Navigate to the folder where you downloaded the plugin and double-click it

  5. Restart Android Studio

To count the lines

  1. Check the statistics option that is visible after installing the plugin
  2. This option is near the run, debug, gradle console, bottom left corner of Android studio

21/05/2015

If you cannot see the Statistics options, do the following:

  1. Select VIEW from the toolbar.

  2. Select TOOLS Windows.

  3. Choose STATISTICS.

You will see the statistics of your project and at the bottom, there is TOTAL section which displays the total lines under the Column of LINES.

David Miguel
14.7k5 gold badges75 silver badges79 bronze badges
answered Apr 28, 2015 at 2:37
Sign up to request clarification or add additional context in comments.

11 Comments

Works with Windows now. Nice.
I'm using Android Studio 1.4.1 and had to use version 2.3 release of the Statistics plugin. The newest versions of Statistics failed to load (2.4 and 2.5). I'm on OSX 10.10.
"Plugins" is located in File --> Settings in the newest version of Android Studio for Windows. I couldn't find it for a while because I was looking for a top-level menu bar entitled "Android Studio", which obviously doesn't exist. Can you update this to reflect that?
Its include R.java and other library file also not up to mark
This crashed my Android Studio 1.5.1.
|
21

You could try this plugin (It is for IntelliJ but should work with AS): http://plugins.jetbrains.com/plugin/?idea&id=4509

answered Aug 26, 2014 at 16:05

2 Comments

It does work with AS, and quite nicely. Just installed for my own project.
Works for me! Android Studio 2.2.3
9

Goto the link https://plugins.jetbrains.com/plugin/4509-statistic and install it.

General Usage Instructions

  1. Install plugin from official Jetbrains plugin site,

  2. After installing, just click on the TAB "Statistic" at the bottom of the screen (left side),

  3. Click "Refresh" button to run statistic for whole project,

  4. Click "Refresh on selection" button to run statistic for selected directory,

  5. Click "Settings" button to customize plugin behavior,

    • Adjust "Excluded file types" with all extensions which you want to remove from the statistic (e.g. class;jar;...),

    • Adjust "Seperate TABs file types" with all extensions which you want to have in separate tab (e.g. php;java;...),

Note:

  1. Size - total size of the file,

  2. Size Min - size of the smallest file of the given type,

  3. Size Max - size of the biggest file of the given type,

  4. Size Avg - average size of the file of the given type.

answered Sep 10, 2019 at 7:30

Comments

3

Jetbrain's statistics plugin is counting only .java files. It is not accurate for getting android app source line of code.

We can use locmatrics for this.

http://www.locmetrics.com/

This will return loc for all the entered extensions.

Please set a valid output directory while checking this. Otherwise garbage files will be generated inside source directory

answered Feb 17, 2016 at 6:27

1 Comment

Update 2021: Url is down
3

If you want to get the number of lines of code in your entire project just write the below line in the terminal of android studio.

git ls-files | xargs wc -l
answered Jul 6, 2023 at 6:50

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.