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

  • SEARCH
  • Home
  • 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 8654591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:49:34+00:00 2026-06-12T14:49:34+00:00

I haven’t been able to find much on this topic. I am trying to

  • 0

I haven’t been able to find much on this topic.
I am trying to automate application testing, to where I place an app in a particular folder and I run the script: monkeyrunner.bat -v ALL myscript.py, and the script executes on whatever apk is in the folder called apkrepository. This makes it to where I do not have to alter my python script every time I test a new application.

The part where I am running into trouble is I am trying to use a variable for device1.installPackage()
See below for the code leading upto it.

installme = os.popen(r'dir C:\users\uname\desktop\apkrepository /A:-d /B').read()
print installme
# => com.application.android.apk #or whatever the package name is

filepath = r'C:\users\uname\desktop\apkrepository'

androidapp = filepath + '\\\' + installme

print androidapp
# => C:\users\uname\desktop\apkrepository\com.application.android.apk
#This exactly what I type below manually to get it to work 

device1= MonkeyRunner.waitForConnection(15, "emulator-5554")
#Emulator was started in previous section of code, which is not shown here.

device1.installPackage(androidapp)
#DOES NOT WORK!!

device1.installPackage('c:\users\uname\desktop\apkrepository\com.application.android.apk')
 #The only way it works seems to be to write the path in manually everytime.

I have tried many different ways to get this to work correctly, and I wasn’t sure if it was something in the way(s) I was/were trying to do it. If the variable prints the correct file path I do not see how it would have issues working. This is probably something really easy, but this is where I am stuck. The error it gives:

E/Device: Error dyring Sync: Local Path does not exist. Error installing package C:\users\uname\desktop\apkrepository\com.application.android.apk

I am using windows 7 64 bit with python2.7 and the android sdk.

Thank you for any input/assistance provided! I have been stumped by this for a couple days.

Variables DO work for other places (monkeyrunner affiliated classes), like the device1.startActivity(component=runcomponent), where runcomponent is a combination of package + activity variables. Also note: I showed both device1.installPackages side by side for easy viewing. I do not run both in a row on my script.

  • 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-12T14:49:35+00:00Added an answer on June 12, 2026 at 2:49 pm

    I tried the same in linux machine, it works. Please have a look at the monkeyrunner script.

    #! /usr/bin/env monkeyrunner
    import re
    import sys
    import os
    import java
    import glob
    import os
    
    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
    device1= MonkeyRunner.waitForConnection(15, "emulator-5554")
    mydir="/home/user/apk"
    os.chdir(mydir)
    for files in glob.glob("*.apk"):
        print files
        print "path " ,os.path.abspath(mydir+"/"+files)
        device1.installPackage(mydir+"/"+files)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Haven't been able to find this one out. How are Bitmaps stored in memory
I haven't been able to get this working and all of the sample code
I haven't been able to find any useful resources online on how to do
I haven't been able to find a tutorial on how to properly setup a
I haven't been able to find authorative explanations, microformats or guidelines for the following,
Haven't been able to figure this out yet.. I've seen a few answers around
I haven't used the STL much before, but I started to on this huffman
Haven't done as much of Javascript as I should have done. I am trying
I haven't been able to understand what the resolution rule is in propositional logic.
I haven't actually built an app yet, but I'm confused by documentation on bind-attr.

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.