Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:41:44+00:00 2026-06-08T06:41:44+00:00

import os def getName(AAPTLocation, apkFile): AAPTLocation = AAPTLocation.replace(‘\\’,’\\\\’) apkFile = apkFile.replace(‘\\’,’\\\\’) pname = ”

  • 0
import os

def getName(AAPTLocation, apkFile):

    AAPTLocation = AAPTLocation.replace('\\','\\\\')
    apkFile = apkFile.replace('\\','\\\\')
    pname = ''
    cmd = ' \"\"' + AAPTLocation + '\" dump badging \"' + apkFile + '\"\"'
    p = os.popen(cmd)
    while 1:
        s = p.readline()
        if s:
            print s
            if s.find('package') != -1 and s.find('name') != -1:
                pname = s  
        if not s:
            break
    p.close()
    return pname

AAPTLocation = 'C:\Program Files\Android\android-sdk\platform-tools\aapt.exe'
apkFile = 'C:\APKs\test.apk'
print getName(AAPTLocation, apkFile)

I need to run aapt.exe, get the package name of the apk and parse the result.

Running “C:\Program Files\Android\android-sdk\platform-tools\aapt.exe” dump badging “C:\APKs\test.apk” directly in the commandline interface is working fine. However in the python script I pasted above it doesn’t give me anything.

I already tried escaping the backslash but it doesn’t make a difference at all. Is there something wrong with my code?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:41:45+00:00Added an answer on June 8, 2026 at 6:41 am

    You need to double the slashes in the python literal, they are being interpreted as the start of an escape code otherwise:

    >>> 'C:\Program Files\Android\android-sdk\platform-tools\aapt.exe'
    'C:\\Program Files\\Android\x07ndroid-sdk\\platform-tools\x07apt.exe'
    >>> 'C:\\Program Files\\Android\\android-sdk\\platform-tools\\aapt.exe'
    'C:\\Program Files\\Android\\android-sdk\\platform-tools\\aapt.exe'
    >>> print 'C:\\Program Files\\Android\\android-sdk\\platform-tools\\aapt.exe'
    C:\Program Files\Android\android-sdk\platform-tools\aapt.exe
    

    Notice how in the first example (from your code) python has interpreted the \a entries as a hex 07 character instead, the ASCII code for BELL.

    The alterative is to use a raw python string literal, by prefixing it with the letter r:

    >>> r'C:\Program Files\Android\android-sdk\platform-tools\aapt.exe'
    'C:\\Program Files\\Android\\android-sdk\\platform-tools\\aapt.exe'
    

    See the string literals documentation for more info on how string escapes work in string literals.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this : import os import subprocess def check_server(): cl = subprocess.Popen([nmap,10.7.1.71], stdout=subprocess.PIPE) result
Given the code: import clr clr.AddReference('System') from System.Text.RegularExpressions import * def ReplaceBlank(st): return Regex.Replace(
from math import * def solution_handler(self, input): while re.search(r'(?<!\.)(\d+)(?!\.)(\d*)', input): rx = re.search(r'(?<!\.)(\d+)(?!\.)(\d*)', input)
import sys def checkarg(): try: filename=str(sys.argv[1]) if filename==-mycommand: print SPECIFIC_TEXT sys.exit() else: return filename
import math def p(n): return 393000*((288200/393000)^n * math.exp(-(288200/393000)))/math.factorial(n) print p(3) When I run it,
The python implementation import sys def move(src, dst, tmp, num): if num == 1:
I have this code: import re def doReplace(toReplace): i = 1 def chapterReplacer(_): result
Following is my code: import zipfile from zipfile import ZipFile def extract(zipFilename, dm_extraction_dir) :
Suppose you have these modules: module1.py import module2 def a(): module1.b() def c(): print
I have the following snippet of code: import csv def has_header(first_lines): sniffer = csv.Sniffer()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.