2

I'm trying to run a sample test for a native Calculator app on a real Android 4.1.2 device. I'm using Appium(run as admin) on Windows, Selendroid and Eclipse. My sample code is

@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "");
capabilities.setCapability("automationName", "Selendroid");
capabilities.setCapability("platformVersion", "4.1.2");
capabilities.setCapability("deviceName","0123456789ABCDEF");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity","com.android.calculator2.Calculator"); 
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

From what i have found on different forums and resources, it is possible to refer to the necessary application only by its package name and the launcher activity(without providing the .apk). However, for some reason Appium fails when not provided with the dump. The log of the failure is

> Checking if an update is available
> Update not available
> Starting Node Server
> info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"16","automationName":"Selendroid"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator2","app":"Calculator.apk","appActivity":"com.android.calculator2.Calculator","BROWSER_NAME":"Chrome","platformVersion":"4.1.2","automationName":"Selendroid","platformName":"Android","deviceName":"0123456789ABCDEF"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5)
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : BROWSER_NAME
> info: [debug] App is an Android package, will attempt to run on device
> info: [debug] Creating new appium session 9942d26b-d1c1-43c8-9c6b-a9c4382d5ac9
> info: [debug] Starting selendroid server
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_45
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:\Android\android-sdk\platform-tools\adb.exe
> info: [debug] Checking whether selendroid is built yet
> info: [debug] Selendroid server exists!
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device 0123456789ABCDEF
> info: [debug] Setting device id to 0123456789ABCDEF
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe -s 0123456789ABCDEF wait-for-device
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe -s 0123456789ABCDEF shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from D:\Android\android-sdk\build-tools\22.0.1\aapt.exe
> info: [debug] Checking if has internet permission from manifest.
> info: [debug] executing cmd: D:\Android\android-sdk\build-tools\22.0.1\aapt.exe dump badging 
> warn: ERROR: no dump file specified
> 
> error: Failed to start an Appium session, err was: Error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified
> 
> info: [debug] Cleaning up appium session
> info: [debug] Error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified
> 
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1661:19
>     at ChildProcess.exithandler (child_process.js:641:7)
>     at ChildProcess.EventEmitter.emit (events.js:98:17)
>     at maybeClose (child_process.js:743:16)
>     at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified\r\n)","origValue":"hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 635.247 ms - 318

Is there a way around this?

Nick Slavsky
  • 1,300
  • 3
  • 19
  • 39
  • You are talking about real device but you defined capabilities.setCapability("deviceName","Emulator"); – Eugene May 02 '15 at 20:15
  • Oops, my bad: I copied and pasted from the wrong place. Corrected. Of course I'm using a real device and Android 4.1.2 just like i mentioned in the post – Nick Slavsky May 03 '15 at 15:15
  • Please see [this link](https://discuss.appium.io/t/setting-up-android-environment-with-selendroid/931) – Eugene May 03 '15 at 20:08
  • Thank you! it looks like a kind of a different problem. Here is the deal. the adb.js file mentioned in the post you provided contains the following line: ` `prettyExec(this.binaries.aapt, ['dump', 'badging', localApk],` - you see, it takes localApk as a parameter and fails when i do not provide it. Other logs i've seen on the web contain the path to the apk file. However my idea is to test the native calculator app, without apk. Am I doomed? should i somehow get that .apk file and pass it as a capability? – Nick Slavsky May 04 '15 at 08:11
  • Did you check calculator APK info on your device? Are you sure that the appPackage and appActivity are correct? – Eugene May 04 '15 at 16:04
  • Yes, I am sure, i got the package name and activity name from the SDK inspector. BTW, i have extracted the APK and provided its path and it got me a bit further. But the question remains: **why does Appium require the path to APK?** – Nick Slavsky May 05 '15 at 11:15

3 Answers3

0

This code works on my Android device. I able to launch the calculator app w/o path to apk.

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("appium-version", "1.1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "my_device_name");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("device", "Android");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
serverAddress = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver(serverAddress, capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Eugene
  • 1,865
  • 3
  • 21
  • 24
0

Here is what i was able to figure out:

  1. Please note that I'm running Android 4.1.2 and have to use Selendroid
  2. Selendroid requires the <uses-permission android:name="android.**permission.INTERNET"/> permission for the app
  3. What i guess here is that it then uses aapt to parse the .apk file, because
  4. Once i provide the .apk file extracted from the phone, it actually passes on to the next step where it parses the manifest and looks for the permission

So to sum up: if i'm using Selendroid, i have to provide .apk and my .apk has to have Internet permission. That is why Calculator test won't work here.

Nick Slavsky
  • 1,300
  • 3
  • 19
  • 39
0

I think the problem will be solved if we rebuild the apk. I faced this issue in the past and I was able to get over it after rebuilding the apk.

Regards Jnaneswar