Move History

Fork Selected
  • Description

    Since I have to work on an Android project which doesn't use Gradle as a build tool, so I always have to find the aar library and extract the classes.jar file from it. Doing it manually was very boring. So I decided to write my own Python (because it's interpreted) script to do this task. The code I have written works very well, but it can be improved by making it cross-platform, efficient, etc.

    So let's start to improve it.

    Gist: https://gist.github.com/pavi2410/b1ba0ae03e4b459846c72453204394a6

    Note that you have to run this script on your PC, unfortunately.

    Code
    import zipfile, os
    
    cd = os.getcwd()
    for file in os.listdir(cd):
    	if file.endswith(".aar"):
    		print("Got aar: " + file)
    		with zipfile.ZipFile(cd + "\\" + file) as aar:
    			aar.extract("classes.jar", cd)
    			print("Extracted aar")
    		os.rename("classes.jar", os.path.splitext(file)[0] + ".jar")