'Installed apk doesn't start
I have to write couple tests on Xamarin UI Test
framework to check apk on emulator. I tried to install my apk in two ways:
1 adb.exe install path\com.company.mobiledemo.apk
2 through Xamarin UI Test
if (platform == Platform.Android)
{
AndroidApp app = ConfigureApp.Android
.ApkFile("path\\com.company.mobiledemo.apk")
.Debug()
.EnableLocalScreenshots()
.DeviceSerial("emulator-5554")
.StartApp();
return app;
}
In first approach apk installed and working correctly. But when apk installed via code above apk will be install but wont launch, just stopped after splash screen.
I have no idea why because both use the same apk file.
NUnit: 3.13.3
NUnit3TestAdapter: 4.2.1
Xamarin.UITest: 2.2.6
Emulator OS: Android 6.0 Api 23
Solution 1:[1]
Ok I found the solution. It's a bit confused and maybe there is a more easy fix. Problem as I understood is your apk and Instrumentation backend apk must be signed the same cert.
My steps:
I installed apk via adb command :
>adb.exe install ~\..\com.company.mobiledemo.apk
Then changed
AppInitializer.cs
like this :if (platform == Platform.Android) { string keystore = "~\\..\\..\\some.keystore"; AndroidAppConfigurator appConfigurator = ConfigureApp.Android .KeyStore( keystore, "storePassword", "keyPassword", "\"keyAlias\"" ) .InstalledApp("com.company.mobiledemo.apk") .Debug() .EnableLocalScreenshots(); AndroidApp app = appConfigurator.StartApp(AppDataMode.Clear); return app; }
Then tried to launch test and got error :
System.Exception : Failed to execute: C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\jarsigner.exe -sigalg SHA1withRSA -digestalg SHA1 -signedjar "C:\Users\{user}\AppData\Local\Temp\uitest\a-287A943C412ED6ED5DEB1675E7FDF91843FD0807\20344\SignedTestServer.apk" -storepass bla-bla -keypass bla-bla -keystore "~..\Mobile\Mobile.Android\Certificate\some.keystore" "C:\Users\{user}\AppData\Local\Temp\uitest\a-287A943C412ED6ED5DEB1675E7FDF91843FD0807\TestServer.apk" ""Key Alias"" - exit code: 1
Please type jarsigner -help for usage
Only one alias can be specified
It's ok.
- Open folder from error message :
C:\Users{user}\AppData\Local\Temp\uitest\
You will see something like this :
- Delete all and run tests once again. After launching new test data will appear:
Copy command from error message above, go to
C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin
or directory where locatedjarsigner.exe
Execute command after
System.Exception : Failed to execute:
- Find
SignedTestServer.apk
and copy it into folder containesdummy.apk
- Run tests once again and see that
FinalTestServer.apk
appeared
PS Close folder C:\Users\{user}\AppData\Local\Temp\uitest
before 9.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ?????? |