How to make local mobile device visible for CI tool - android

I am building automation project and want to run tests automatically on local mobile device, that connected to my machine. For that I uploaded my project to GitLab, created .yml file with commands in CI/CD and created schedule.
The next chalenge:
to run tests automatically, on mobile device connected to my machine.
Is any options to make local device visible for GitLab CI/CD?

On your local machine, install the gitlab-runner and register it to your GitLab project. In order to use the device, you'll need to use the shell executor. Be sure to specify at least one unique tag for the runner (say, android for example)
In your yaml, add the tag you used for your runner in the tags: key. For example:
myjob:
tags:
- android
script:
# ...
This will make sure that only your runner will pick up the job.

Related

Android: set package name depending on device running on

I have functional autotests for some SDK (as aar-libs) and TeamCity CI server with several Android devices and emulators connected on.
If I use gradle to run my tests (./gradlew connectedDebugAndroidTest), all tests will run on each device, but each next results will overwrite previous ones and TeamCity will show only the last results.
I have to distinct these results and should know which results from what device/emulator.
Any ideas?
Decided to create additional build configuration on Team City, which will parse all connected devices from adb devices and trigger all other configurations passing device name as parameter

Is it possible to build a react native application for Android without running an emulator?

When building a react-native project for android you run the following command
react-native run-android --variant=release
However for a successful release build an android emulator needs to be running. If it's not you'll get the following error:
* What went wrong:
Execution failed for task ':app:installRelease'.
> com.android.builder.testing.api.DeviceException: No connected devices!
But I don't want to start an emulator because I'm building the project in a container that doesn't support android emulators.
Is it possible to build a react native application for Android without running an emulator?
Note:
A physical device won't work because I'm working with containers that are running in CircleCI which is a Cloud-based Continuous Integration service.
The react-native command line utility wraps another utility called gradlew (which is in fact another wrapper for gradle that will download gradle if it doesn't already exist).
The gradlew utility lives inside the android directory and can be used directly like this:
cd android
./gradlew assembleRelease
So if you're wanting to build a release Android Package (APK) but not run it on an emulator then the above command will work!
You could test your app in browser. But which need some third-party tools, such as https://snack.expo.io/, and here is a good tutorial about using it.
Why not just use a physical device?
As long as you have followed these steps:
1. Open the Settings app.
2. (Only on Android 8.0 or higher) Select System.
3. Scroll to the bottom and select About phone.
4. Scroll to the bottom and tap Build number 7 times.
5. Return to the previous screen to find Developer options near the bottom.
you can enable USB debugging on your device under developer options. After enabling USB debugging, react-native will target your device and install the release apk.

Debugging whilst developing JavaFX mobile application with gluon mobile plugin

I am new to javaFx and gluon mobile. In android studio there is the option to debug code whilst it is running on the phone and I was wondering if there is a similar feature for working with intelij and the gluon mobile plugin ? Under the gradle tasks there is a Debug task, which when clicked prints "Listening for transport dt_socket at address: 5005" to the console and waits. Unfortunately there is not a lot of documentation/examples regarding this that I could find. Any help is appreciated.
The Debug task is for desktop only.
It is intended to debug easily on your machine before deploying to mobile, but obviously it will allow tracking down only common issues, and that won't guarantee that the app will work on Android. I.e. using Streams will run on desktop and it will fail on Android.
To debug the app running on Android, the best way is using adb from your Android SDK folder, in the platform-tools folder.
Connect your app to the USB and run it. On a terminal go to that folder and run:
adb logcat -v threadtime
and search through all the messages trying to find out those related to the FXActivity.
You can add print outs in your code so you can easily track them in the logs.
There are other tools like the Android monitor (under Android sdk/tools folder), that will let you add some filters so you can easily go through the app messages.
First make sure you have enabled the Debugging Mode on your phone.
Then in Eclipse e.g., you can create a Debug Configuration of type Remote Java Application which will be attached to the corresponding socket:
You can get the port from the devices view:
Now you have to start your app first, and then start the Debug Configuration

How to run meteor iOS app with localhost (not with live server)?

My project is deployed on live server; I want to make some customization, but it's live, so I am having same backup on Mac and doing customization. I just put this code (meteor run ios-device --mobile-server=http://localhost:3000 --production) in run-mobile.sh and I ran the same command (meteor run ios-device --mobile-server=http://localhost:3000 --production) in meteor directory.
My application is getting open in Xcode simulator and running well, but I am unable to see my customized code: it's still showing codes coming from server, but I want to run the iOS app with localhost, not with live server.
Does there need to be any other file, or do I need to change that file which I did not find? If so, where I can found that to set localhost?
If you execute just meteor run ios-device, it starts a local meteor server and opens Xcode. No need for the --mobile-server option.
You also don't need the --production option. According to the meteor help, it's just to:
Simulate production mode. Minify and bundle CSS and JS files.

Phonegap app for iOS without Phonegap Build

So I asked and answered the question [how to do Phonegap 3.0 without Phonegap Build][1]. Now my app is ready for iOS as well (I think) and it's time to start deploying and debugging for that platform.
The formal question: how can I add the iOS platform to a Phonegap 3.0 project?
This answer is still in progress.
Goals I've achieved:
Compiling the project in command line, then running on device or sim using xCode
Attempts failed:
Compiling and running (device/sim) all from the command-line
1. Creation
I could easily add the iOS platform as described in the docs' iOS Platform Guide.
Basically, if the project already exists because you did Android first, this is how you set up the iOS app structure.
$ add platform ios
Then you should add files to the main /www folder if you didn't already have them from your Android work. Then this takes care of creating the app in debug form:
$ cordova prepare //Creates all the necessary source filed
$ cordova compile //Creates an ipa file
//Alternatively, do both in one go with cordova build
2. Deploying to device
But it is completely unclear how to use the command line interface to actually deploy the test app to device or emulator.
When you attach a physical iOS device, and simply try this from the main project folder...
$ cordova run ios
You get a pretty clear answer:
[Error: An error occurred while running the ios project. Targeting a device is not supported currently.
]
So I've resigned myself that for device testing, I must still use xCode. No biggie. However, xCode cannot "refresh" the project by itself after you've updated your files, so in between deploys you must go back to the command-line to recompile the iOS app.
Strangely, when I update my code, I do need to use "cordova run ios" (even with the above error) in order for the the /platforms/ios/www folder to be updated. So this is what works and does not work:
$ cordova run ios
//Rebuilds the app with main /www files successfully,
//then tries to deploy to device and fails in that.
$ cordova prepare ios
//Does not rebuild with main /www files
//(Also does not deploy but that is not its intended function)
And remember that you also need to clean your xCode project in between runs. So the sequence is:
Previous run
Edit your code
In console, do: cordova run ios
In xCode, Menu bar > Product > Clean product
in xCode, Run
3. Deploying to emulator
Still, "deploying to device is not possible" begs the question "What about emulator?"...
The docs page on the 3.0 command-line interface mentions you should enter the command
$ /path/to/my_new_project/cordova/run
This had me all confused. What kind of path is that? From where are you supposed to run it? Is it a nice way of providing a command you can run from anywhere? Why force me to enter my annoyingly long project path for each command?
Confusingly, the run command doesn't work if you actually go to the "platforms/ios/cordova" directory where the run executable is located.
The trick is to be one directory lower, i.e. at the /platforms/ios subfolder of your Cordova app project. There you type "cordova/run". Then in my case it starts building.
4. Install "ios-sim"
But that was not the end of it. I subsequently get an unanticipated error about "ios-sim" not being installed.
[...]
** BUILD SUCCEEDED **
Error: ios-sim was not found. Please download, build and install version 1.5 or greater from https://github.com/phonegap/ios-sim into your path. Or 'brew install ios-sim' using homebrew: http://mxcl.github.com/homebrew/
Fortunately that project webpage has adequate documentation on how to install. However, even after adding the ios-sim directory to my $PATH, when I want to emulate I get the following error.
$ cordova emulate ios
[TypeError: Arguments to path.join must be strings]
This is where I am currently stuck. My path looks exactly like this (all in one line):
export PATH=${PATH}:/Applications/adt-bundle/
sdk/platform-tools:/Applications/adt-bundle/sdk
/tools:%JAVA_HOME%\bin%ANT_HOME%\bin:"/Users/
cool/Library/Developer/iossim"
What am I doing wrong? I've tried with and without doublequotes, and I've even renamed the ios-sim directory to iossim in case the hyphen was the problem. No effect.
So no simulator for now.
5. Install to iOS App Store
This is the point where Phonegap really leaves you out in the woods. Maybe because they want you to use their paid app publishing service, but also because the process of publishing an iOS app is basically soemthing you do using xCode, iOS Developer Portal, and iTunes Connect.
So here that goes:
You need to have all the right certificates and profiles for your app (yes, it's a bunch of incomprehensible virtual documents that all require each other, Apple is like the Soviet Union of app stores).
You request those certificates and profiles in the iOS Developer Portal, save them to disk, then double-click them so that xCode knows you have them and will include them in your app.
This is the docs page for xCode 4 on how to publish your app.
The most counter-intuitive bit is that in order to publish your app, you first have to create an archive of it in xCode (Open your project in xCode > menu bar > Product > Archive).
When the archive is made, you will see it in the Organizer view under the Archives tab. There should be two buttons: Validate and Distribute. Validate checks and includes all your profiles and certificates in the app, and it also checks for errors like a wrong version number.
Distribute does what it says: it sumbits the app to the App Store.
Congratulations! (Now wait five days)

Categories

Resources