Checking whether aapt is present hits error while getting badging info

I am trying to learn Appium, using the instructions given in the documentation:

I am running on Windows 10 Pro for Workstations.

http://appium.io/docs/en/about-appium/getting-started/?lang=en

I have put this code into a file called AppiumTest.js

const wdio = require(‘webdriverio’);

const opts = {
port: 4723,
desiredCapabilities: {
platformName: “Android”,
platformVersion: “8.0”,
deviceName: “Pixel_API_26”,
app: “C:/Users/SStaple/AppData/Local/Android/Sdk/ApiDemos-debug.apk”,
automationName: “UiAutomator2”
}
};

const client = wdio.remote(opts);

client
.init()
.click(“~App”)
.click(“~Alert Dialogs”)
.back()
.back()
.end();

I am running it from the Node.js command prompt, using the command: node AppiumTest.js, after starting the Appium Server. It was also necessary to have an Android 8 emulator running.

(Appium Server v1.7.1)

I am getting an output in the Appium Server window. There are a number of errors. The first error shown is this:

Error “Command ‘C:\Users\SStaple\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe d badging C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk’ exited with code 1” while getting badging info

I have tried running this command on its own in the Command Prompt:

C:\Users\SStaple\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe d badging C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk

The result I get here is this:

W/zipro (13656): Error opening archive C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk: Invalid file

ERROR: dump failed because no AndroidManifest.xml found
Any ideas?

Update 28/12/2017

Although I found a solution to this, it keeps re-occurring!
The file appium-uiautomator2-server-v0.1.8.apk was dodgy - only 0 KB in size, so I downloaded another one from Releases · appium/appium-uiautomator2-server · GitHub and used that instead. This one is 1,518 KB in size.

However, every time I run my appiumTest, it gets overwritten with rubbish again! Back to 0 KB.

I have found a solution to this:
there is some problem with npm not putting that apk file into the right place while beta is installed. I downloaded the apk file from https://github.com/appium/appium-uiautomator2-server/releases and put it at the path mentioned in the error message.

I am running into this same issue and am wondering if it is because I am behind a proxy server. I tried the solution above, but am running into this error after replacing the invalid (size 0kb) apk with the one from github (size 1.5mb).

[ADB] App not signed with debug cert.
[ADB] Resigning apk.
[ADB] Error: Could not sign with default certificate.

I then noticed that the apk is again corrupted (size is again 0kb).

Has anyone else been able to come up with a solution for this?

Heh, so on a whim I deleted the “required”

“automationName”: “UiAutomator2”,

from the capabilities and everything works great. Not sure how, but it does.