Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Code Analysis using FindBugs Plugin in Android Studio

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.59k
    Comment on it

    Android has Lint for checking errors in Java and XML code. Lint release with every new SDK.

    But Lint is not find most type of bugs,exceptions and performance issue.

    I found one plugin for static analysis tools to analysis android Java code.

    It helps to improve code quality and application performance.


    FindBugs divided Issues into 9 categories that are:

    1. Dodgy code
    2. Malicious code vulnerability
    3. Bad practice
    4. Correctness
    5. Internationalization
    6. Security
    7. Performance
    8. Multi-threaded correctness
    9. Experimental


    Steps to Add plugin into Android Studio
    1. Open File.
    2. Click on Settings
    3. then Plugins and search for FindBugs.


    Now Run FindBugs for your project/file.

    FindBugs report many issues like "Bad Practice" when you run first time. That issues are part of automatically generated files.

    For ignore issues like this FindBugs has functionality to add exclude issues. To ignore "Bad Practice issue" for automatically generated files and code Create xml file in root of project and Add the below code to it.


    <?xml version="1.0" encoding="UTF-8"?>  
    

    < FindBugsFilter>
    < Match>
    < !-- ignore all issues in resource generation -->
    < Class name="~.*\.R\$.*"/>
    < /Match>
    < Match>
    < Class name="~.*\.Manifest\$.*"/>
    < /Match>
    < /FindBugsFilter>

    Open Settings and click on FindBugs.
    Click on Filter then click on Add Exclude filter.
    add above generated xml file and test your code.


    Please let me know if there is any query.

    References:- FindBugs plugin



    Happy Coding.


    Cheers!!



    alt text


    image1


    alt text

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: