GithubHelp home page GithubHelp logo

keepsafe / android-resource-remover Goto Github PK

View Code? Open in Web Editor NEW
1.3K 63.0 162.0 103 KB

A simple utility to remove unused resources in your Android app to lower the size of the APK. It's based on the Android lint tool output.

License: Apache License 2.0

Python 75.31% Makefile 15.22% Java 9.47%

android-resource-remover's Introduction

Build Status

resource-remover android-resource-remover

android-resource-remover is utility that removes unused resources reported by Android Lint from your project. The goal is to reduce your APK size and keep the app clean from unused stuff.

Getting started

Requirements:

  • Python >= 2.7.*
  • ADT >= 16

To install run:

pip install android-resource-remover

Usage - general

Open the directory where your app is located and run

android-resource-remover

Android resources have dependencies to each other. This means that after running resource-remover the first time, it will clean up unused resources file that hold a reference to other resources. You can run this resource remover multiple times until there is no more unused resources to be removed. We've been running it up to 4 times in a row.

Use with gradle

android-resource-remover is build on top of android lint. If you have a gradle project you have to run lint within your gradle build scripts and then use the lint-result.xml as the input file for android-resource-remover

e.g.

./gradlew clean build :lint && android-resource-remover --xml build/outputs/lint-results.xml

Options

--help

Prints help message.

--lint

Full path to the lint tool like: d:\Dev\Android SDK\tools\lint

This will be executed as the lint command. If not provided it assumes the lint command in available and runs: lint

--app

Full path to the android app like: d:\Dev\My_Android_App

If not provided it assumes the current directory is the app's root directory.

--xml

Use existing lint result. If provided lint won't be run.

--ignore-layouts

Ignore layout directory

Expected behavior

Resource ID in code not found

If you have references to elements in an old layout that you're not using anymore, you will get a compile error that the ID (R.id.<something>) can not be found. The reason is that the resource file that contained R.id.<something> has been removed as it was not used any more. Time to clean up your code.

FAQ

Q: installing dependency lxml failed with clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
A: http://stackoverflow.com/a/22322645

Q: installing dependency lxml failed with fatal error: 'libxml/xmlversion.h' file not found
A: There are several ways to fix this listed on stackoverflow http://stackoverflow.com/questions/19548011/cannot-install-lxml-on-mac-os-x-10-9

Issues and PR

When opening an issue please include as much info as possible. pip.log, python varsion/info, os version/info might all be help us understanding what's the problem.

In PR please keep the formatting.

Licence

Apache version 2.0

android-resource-remover's People

Contributors

ca77y avatar fafhrd91 avatar gitter-badger avatar mrmaffen avatar philippb avatar snejku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-resource-remover's Issues

OSError: [Errno 2] No such file or directory

Run the "android-resource-remover" command in ubuntu, it's output error:
Traceback (most recent call last):
File "/usr/local/bin/android-resource-remover", line 9, in
load_entry_point('android-resource-remover==0.1.5', 'console_scripts', 'android-resource-remover')()
File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 141, in main
lint_result_path, app_dir, ignore_layouts = run_lint_command()
File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 77, in run_lint_command
call_result = subprocess.call([lint, app_dir, '--xml', lint_result])
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(_popenargs, *_kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

unicodeDecodeerror

         I run the command "pip instatll android-resource-remover", then received an error like that:

unicodeDecodeerror gbk codec can't decode byte 0x80

Incorrectly removes string referenced in AndroidManifest.xml

After running android-resource-remover:

Error:

AndroidManifest.xml:7: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:versionCode="1"
      android:versionName="1.0" package="com.readystatesoftware.viewbadger">
    <uses-sdk android:minSdkVersion="4" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name="viewbadger.demo.DemoActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

3rd part res

when we develop android app, we import 3rd part dependency. Some of them have resource, which should be imported by handle. some 3rd part resource are used, some are not used.

how to remove these resource without using?

UnicodeDecodeError

UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 3077: illegal multibyte sequence

pin install error

Python 2.7.10
pip 7.1.1 from /Library/Python/2.7/site-packages (python 2.7)
Mac OS X 10.11.4
Xcode 7.3

Same error with easy_install

Building lxml version 3.6.0.
Building without Cython.
Using build configuration of libxslt 1.1.28
running install
running build
running build_py
copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.11-intel-2.7/lxml/includes
running build_ext
building 'lxml.etree' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -Isrc/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.11-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
In file included from src/lxml/lxml.etree.c:320:
src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
         ^
1 error generated.
Compile failed: command 'cc' failed with exit status 1
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /var/folders/g7/_2r9d3rx1w5d_jl0kf2h5w7r0000gp/T/xmlXPathInitLGKTsq.c -o var/folders/g7/_2r9d3rx1w5d_jl0kf2h5w7r0000gp/T/xmlXPathInitLGKTsq.o
/var/folders/g7/_2r9d3rx1w5d_jl0kf2h5w7r0000gp/T/xmlXPathInitLGKTsq.c:1:10: fatal error: 'libxml/xpath.h' file not found
#include "libxml/xpath.h"
         ^
1 error generated.

What's the problem when excute comment

do commend(android-resource-remover) with follow error

Traceback (most recent call last):
File "D:\Python27\Scripts\android-resource-remover-script.py", line 9, in
load_entry_point('android-resource-remover==0.1.4', 'console_scripts', 'android-resource-remover')()
File "D:\Python27\lib\site-packages\android_clean_app.py", line 141, in main
lint_result_path, app_dir, ignore_layouts = run_lint_command()
File "D:\Python27\lib\site-packages\android_clean_app.py", line 78, in run_lint_command
call_result = subprocess.call([lint, app_dir, '--xml', lint_result])
File "D:\Python27\lib\subprocess.py", line 522, in call
return Popen(_popenargs, *_kwargs).wait()
File "D:\Python27\lib\subprocess.py", line 710, in init
errread, errwrite)
File "D:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)

“lint” command success alone

pip install error

bogon:~ hubin$ pip install android-resource-remover
Collecting android-resource-remover
Using cached android-resource-remover-0.1.5.tar.gz
Requirement already satisfied (use --upgrade to upgrade): lxml>=3.3.3 in /Library/Python/2.7/site-packages (from android-resource-remover)
Installing collected packages: android-resource-remover
Running setup.py install for android-resource-remover
Complete output from command /usr/bin/python -c "import setuptools, tokenize;file='/private/var/folders/t0/sl2174ps6dq7__dr4cbvrm7h0000gn/T/pip-build-IAYg_g/android-resource-remover/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/t0/sl2174ps6dq7__dr4cbvrm7h0000gn/T/pip-9aRlIK-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib
copying android_clean_app.py -> build/lib
running install_lib
copying build/lib/android_clean_app.py -> /Library/Python/2.7/site-packages
error: could not delete '/Library/Python/2.7/site-packages/android_clean_app.py': Permission denied

----------------------------------------

Command "/usr/bin/python -c "import setuptools, tokenize;file='/private/var/folders/t0/sl2174ps6dq7__dr4cbvrm7h0000gn/T/pip-build-IAYg_g/android-resource-remover/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/t0/sl2174ps6dq7__dr4cbvrm7h0000gn/T/pip-9aRlIK-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/t0/sl2174ps6dq7__dr4cbvrm7h0000gn/T/pip-build-IAYg_g/android-resource-remover

Does not keep newline at end of file and xml header

Unnecessary change is applied when remover modifies content of xml files.

-<?xml version="1.0" encoding="utf-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
-</resources>
+</resources>
\ No newline at end of file

IOError: Error reading file 'build/outputs/lint-results.xml'

Hi,
Unfortunately, I wasn't able to get it into for two days so decided to get some help.
For some reasons I'm not able to use your suggested command, ./gradlew clean build :lint && android-resource-remover --xml build/outputs/lint-results.xml.

  • build tries to create a release and since I'm work on company project and its credential isn't in build.gradle file so process fails.
  • Gradle :lint is not in root of your project.

So what I do is I first create a debug .apk in normal way. Second, I run lint from Gradle window, My-app/app/verification/lint. So lint-results.xml will be created in my build/output folder. I run this command in terminal now android-resource-remover --xml build/outputs/lint-results.xml. Then I get following error.

I'm using Android Studio 2.0 Preview 5 on Ubuntu 14.04 LTS. Any suggestion would be appreciated. Thanks.

screenshot from 2016-01-19 12 23 52

IOError when both resource (xml) file and containing string are unused

xml file is removed first and IOError happens when tries to remove string resource entry.

removing resource: /path/to/our/app/src/main/res/xml/ecommerce_tracker.xml
removing ('string', 'ga_trackingId') from resource /path/to/our/app/src/main/res/xml/ecommerce_tracker.xml
Traceback (most recent call last):
  File "/Users/yuya.tanaka/.anyenv/envs/pyenv/versions/2.7.9/bin/android-resource-remover", line 11, in <module>
    sys.exit(main())
  File "/Users/yuya.tanaka/.anyenv/envs/pyenv/versions/2.7.9/lib/python2.7/site-packages/android_clean_app.py", line 143, in main
    remove_unused_resources(issues, app_dir, ignore_layouts)
  File "/Users/yuya.tanaka/.anyenv/envs/pyenv/versions/2.7.9/lib/python2.7/site-packages/android_clean_app.py", line 137, in remove_unused_resources
    remove_resource_value(issue, filepath)
  File "/Users/yuya.tanaka/.anyenv/envs/pyenv/versions/2.7.9/lib/python2.7/site-packages/android_clean_app.py", line 120, in remove_resource_value
    tree = etree.parse(filepath, parser)
  File "lxml.etree.pyx", line 3310, in lxml.etree.parse (src/lxml/lxml.etree.c:72517)
  File "parser.pxi", line 1791, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:105979)
  File "parser.pxi", line 1817, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:106278)
  File "parser.pxi", line 1721, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:105277)
  File "parser.pxi", line 1122, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:100227)
  File "parser.pxi", line 580, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:94350)
  File "parser.pxi", line 690, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:95786)
  File "parser.pxi", line 618, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:94818)
IOError: Error reading file '/path/to/our/app/src/main/res/xml/ecommerce_tracker.xml': failed to load external entity "/path/to/our/app/src/main/res/xml/ecommerce_tracker.xml"

"Running the command failed"

When I run android-resource-remover inside the project directory under Ubuntu Trusty, it results in:

*Help text*
[...]
Running the command failed. Try running it from the console. Arguments for subprocess.call: ['lint', '.', '--xml', './lint-result.xml']
Traceback (most recent call last):
  File "/usr/local/bin/android-resource-remover", line 9, in <module>
    load_entry_point('android-resource-remover==0.1.0', 'console_scripts', 'android-resource-remover')()
  File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 137, in main
    issues = parse_lint_result(lint_result_path)
  File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 85, in parse_lint_result
    root = ET.parse(lint_result_path).getroot()
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 647, in parse
    source = open(source, "rb")
IOError: [Errno 2] No such file or directory: './lint-result.xml'

UnicodeEncodeError when running

android-resource-remover --xml app/build/outputs/lint-results.xml
Traceback (most recent call last):
File "/usr/local/bin/android-resource-remover", line 9, in
load_entry_point('android-resource-remover==0.1.5', 'console_scripts', 'android-resource-remover')()
File "build/bdist.macosx-10.11-intel/egg/android_clean_app.py", line 143, in main
remove_unused_resources(issues, app_dir, ignore_layouts)
File "build/bdist.macosx-10.11-intel/egg/android_clean_app.py", line 135, in remove_unused_resources
remove_resource_file(issue, filepath, ignore_layouts)
File "build/bdist.macosx-10.11-intel/egg/android_clean_app.py", line 107, in remove_resource_file
print('removing resource: {0}'.format(filepath))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 19-23: ordinal not in range(128)

os: mac
python version: 2.7.10

Remove strings from other locals that are marked as translatable="false"

Android supports translatable="false" in the <string> tag. Strings that are marked as false should be removed from other locales. This will help for the case that they got translated by accident.

Compiling will give the following error when not.

/Users/philipp/coding/keepsafe/app/src/main/res/values-es/material-strings.xml:2 : warning: string 'transition_thumbnail' marked untranslatable but exists in locale 'es'

It would be great to support ExtraTranslation removal

Here the XML node with lint 24.0.1

    <issue
        id="ExtraTranslation"
        severity="Error"
        message="&quot;`loading_more`&quot; is translated here but not found in default locale"
        category="Correctness:Messages"
        priority="6"
        summary="Extra translation"
        explanation="If a string appears in a specific language translation file, but there is no corresponding string in the default locale, then this string is probably unused. (It&apos;s technically possible that your application is only intended to run in a specific locale, but it&apos;s still a good idea to provide a fallback.).

Note that these strings can lead to crashes if the string is looked up on any locale not providing a translation, so it&apos;s important to clean them up."
        errorLine1="    &lt;string name=&quot;loading_more&quot;>Chargement&lt;/string>"
        errorLine2="            ~~~~~~~~~~~~~~~">
        <location
            file="res/values-fr/strings.xml"
            line="5"
            column="13"/>
    </issue>

Problem removing unused dimens and strings

When using the latest version of your script, the console output correctly prints out the message

removing ('dimen', "<dimen_name>") from resource ./res/values/dimens.xml
removing ('string', "<string_name>") from resource ./res/values/strings.xml

for all dimens and strings files but doesn't actually remove the said unused resource from the file. Is this a known issue?

oh,no

It cleaned all my resources in drawable-*dpi,but kept the unused resource

failed to install

# pip install android-resource-remover

in terminal : at the very bottom

Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/ht/sg39cnfx7b7fpz5jx65r8tvc0000gp/T/pip-build-CuOnJy/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/ht/sg39cnfx7b7fpz5jx65r8tvc0000gp/T/pip-_D9qqa-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/ht/sg39cnfx7b7fpz5jx65r8tvc0000gp/T/pip-build-CuOnJy/lxml

Environment :

OSX El-Capitan
XCode CLI Is installed

Why i got an error when running android-resource-remover

Traceback (most recent call last):
File "D:\Python\lib\runpy.py", line 162, in run_module_as_main
"main", fname, loader, pkg_name)
File "D:\Python\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "D:\Python\Scripts\android-resource-remover.exe__main
.py", line 9, in

File "D:\Python\lib\site-packages\android_clean_app.py", line 141, in main
lint_result_path, app_dir, ignore_layouts = run_lint_command()
File "D:\Python\lib\site-packages\android_clean_app.py", line 78, in run_lint_
command
call_result = subprocess.call([lint, app_dir, '--xml', lint_result])
File "D:\Python\lib\subprocess.py", line 522, in call
return Popen(_popenargs, *_kwargs).wait()
File "D:\Python\lib\subprocess.py", line 710, in init
errread, errwrite)
File "D:\Python\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2]

install failed

sudo -H pip install android-resource-remover
Requirement already satisfied (use --upgrade to upgrade): android-resource-remover in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): lxml>=3.3.3 in /Library/Python/2.7/site-packages (from android-resource-remover)

I have no idea ,could you help me?

pip install android-resource-remover, fail

RambowdeMacBook-Pro:~ rambow$ pip install android-resource-remover
Collecting android-resource-remover
/Library/Python/2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached android-resource-remover-0.1.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "/private/var/folders/df/b8ktrgmx1hz761_0wy30v_zw0000gn/T/pip-build-GyYpfS/android-resource-remover/setup.py", line 14, in
long_description='\n\n'.join((read('README.md'), read('CHANGELOG'))),
File "/private/var/folders/df/b8ktrgmx1hz761_0wy30v_zw0000gn/T/pip-build-GyYpfS/android-resource-remover/setup.py", line 8, in read
return open(os.path.join(os.path.dirname(file), f)).read().strip()
IOError: [Errno 2] No such file or directory: '/private/var/folders/df/b8ktrgmx1hz761_0wy30v_zw0000gn/T/pip-build-GyYpfS/android-resource-remover/README.md'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/df/b8ktrgmx1hz761_0wy30v_zw0000gn/T/pip-build-GyYpfS/android-resource-remover

Execution Error; Seeking Help

After installing (via sudo pip install android-resource-remover) successfully, cd-ing into the app directory and executing android-resource-remover I receive the following error:

Traceback (most recent call last):
  File "/usr/local/bin/android-resource-remover", line 9, in <module>
    load_entry_point('android-resource-remover==0.1.5', 'console_scripts', 'android-resource-remover')()
  File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 141, in main
    lint_result_path, app_dir, ignore_layouts = run_lint_command()
  File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 77, in run_lint_command
    call_result = subprocess.call([lint, app_dir, '--xml', lint_result])
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Environment :

  • Linux Ubuntu 14.04 LTS
  • Python 2.7.6
  • Android Studio 1.3
  • JRE 1.8

Help Appreciated :)

Exception: `lint` executable could not be found

Hi, I have this error when I run " android-resource-remover"

Traceback (most recent call last):
File "/usr/local/bin/android-resource-remover", line 9, in
load_entry_point('android-resource-remover==0.1.7', 'console_scripts', 'android-resource-remover')()
File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 196, in main
lint_result_path, app_dir, ignore_layouts = run_lint_command()
File "/usr/local/lib/python2.7/dist-packages/android_clean_app.py", line 94, in run_lint_command
'%s executable could not be found and path to lint result not specified. See --help' % lint)
Exception: lint executable could not be found and path to lint result not specified. See --help

Gradle command fails

I ran the command
./gradlew clean build :lint && android-resource-remover --xml build/outputs/lint-results.xml
and got this

  • What went wrong:
    Task 'lint' not found in root project 'android-nag-client'. Some candidates are: 'init'.

build gradle task

Build a gradle task that makes is easy to integrate this into a build system.

Can't able to run

I've encountered the error below.
Any idea to fix? Thanks.

$ android-resource-remover
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/android-resource-remover", line 9, in <module>
    load_entry_point('android-resource-remover==0.1.5', 'console_scripts', 'android-resource-remover')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/android_clean_app.py", line 141, in main
    lint_result_path, app_dir, ignore_layouts = run_lint_command()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/android_clean_app.py", line 77, in run_lint_command
    call_result = subprocess.call([lint, app_dir, '--xml', lint_result])
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

integrate python code

Hello, I wonder that how did you integrate python code in your java code? Which plugin or component did you use for it?

Thanks in advance :)

error when install from pip

Collecting android-resource-remover
Using cached android-resource-remover-0.1.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "C:\Users\CHENGW1\AppData\Local\Temp\pip-build-tuk9atu3\android-resource-remover\setup.py", line 15, in
long_description='\n\n'.join((read('README.md'), read('CHANGELOG'))),
File "C:\Users\CHENGW
1\AppData\Local\Temp\pip-build-tuk9atu3\android-resource-remover\setup.py", line 9, in read
return open(os.path.join(os.path.dirname(file), f)).read().strip()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 2747: illegal multibyte sequence

install fail

In file included from src/lxml/lxml.etree.c:239:
/private/var/folders/_p/xb0p4rxn50z_nzvv_1vj9mkw0000gq/T/pip-build-3XWO9K/lxml/src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools, tokenize;__file__='/private/var/folders/_p/xb0p4rxn50z_nzvv_1vj9mkw0000gq/T/pip-build-3XWO9K/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/_p/xb0p4rxn50z_nzvv_1vj9mkw0000gq/T/pip-XQZTXI-record/install-record.txt --single-version-externall

Didn't work

Hii, quite simply, I stumbled upon your code through google, and my gradle build is failing due to missing resources. Just FYI, I'll let you know if I have more conclusive info. Need to update lint and get lint working properly as well, will let you know.

A problem with Gradle.

I am very sorry to trouble you. But when i used with Gradle, the unused pictures won't be deleted.
I have runned lint and lint-results.xml are in build/ouputs directory. the i run ./gradlew lint && android-resource-remover --xml build/outputs/lint-results.xml and it build successful.
But i find the unused pictures are still in.

Is any where i used wrong? Please help me find it.Thank you very much.

Need clarification

@ca77y So i ran your tool with lint results xml file and it gave me a bunch of output mentioning removing strings ...
all the output was mentioning removal of strings from libraries that are used inside the project, none of the actual unused resources from strings.xml and drawable folders were removed. I ran lint again in android studio and all the unused icons were still there

pip install error on Windows: UnicodeDecodeError:

pip install android-resource-remover

Collecting android-resource-remover
Using cached android-resource-remover-0.1.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "C:\Users\asm\AppData\Local\Temp\pip-build-oa9d_rfx\android-resource-remover\setup.py", line 15, in
long_description='\n\n'.join((read('README.md'), read('CHANGELOG'))),
File "C:\Users\asm\AppData\Local\Temp\pip-build-oa9d_rfx\android-resource-remover\setup.py", line 9, in read
return open(os.path.join(os.path.dirname(file), f)).read().strip()
File "c:\software\python 3.5.1\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x83 in position 3075: character maps to

----------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.