An example of developing a mobile application using the "Mobile Application Builder". Tatyana Golikova: new demographic measures will appear in Russia Assembly of a 1c mobile application

On September 28 of this year, 1C, without much noise and pathos, released an evaluation version of the platform 8.3.2.163, which was intended for testing. Those interested can read the full list of changes and improvements or, if they have a subscription, .
Of the listed improvements, I think the “Mobile Platform 1C: Enterprise 8” is quite “tasty”, which allows you to create an application for Android or iOS mobile operating systems using the usual 1C tools

Mobile platform, as the developers themselves write, “is the general name for a technology that allows you to create applications that run on mobile devices running the Android or iOS operating systems.”
“A mobile application installed on a device is a combination of a mobile platform and an information base.”

That is, to put it simply, you can compile your written configuration into an application for Android (.apk) or iOS (.zip). Then all this stuff can be posted on Google Play or AppStore. True, if an Android program can be signed with the key created there immediately in 1C, and it will be ready for publication immediately, then to publish the application in the AppStore it will first have to be compiled using the Xcode program on a computer with the Mac OS X operating system. And, Of course, publishing in any of these stores requires a developer license.
Everything sounds good, and I naturally wanted to try out the new features in action.

Creating a mobile application on 1C

To do this, we need a new version of the platform (), a file that takes , android SDK and JDK.
I’ll warn you right away: I’m not currently setting myself the task of showing the process of developing something specific on 1C, but I just want to check and show you that - yes, the world has gone crazy and you can really write a program for Android on 1C.
Well, let's try to write a kind of “helloWorld” for Google Phone. Let's make a program for test purposes - a configuration with one general form, which we will put on the “desktop”.
So, we create a new configuration in managed mode, and the first thing we must do, if we are writing for a mobile platform, is to indicate “Purpose of use” in the properties of the configuration itself.

And here we immediately notice that many configuration objects have become unavailable for use. We will no longer be able to use subsystems, routine tasks, XDTO packages, Web services, reports, business processes and much more. Also, many procedures and methods for some objects are not available. This should be taken into account when developing.
We make a “form”, create a string attribute with the title: “Hello, Habr!” - and throw it onto the form. Let's also create a button. In click processing, we will write a message output, for example.

&OnClient Procedure Command1(Command) Warning("It works!"); EndProcedure

This is enough for us to check its functionality, so let’s get to the fun part. We save the configuration to a file for the mobile application (Configuration->Mobile application->Write to file), launch in managed mode, and start processing MobileAppWizard.epf. This file is in the mobile.zip archive, which we downloaded at the very beginning.
And now we are asked to fill out the initial settings, where all required fields are underlined in red.

Mobile platform location - the directory in which the android.zip and ios.zip files necessary to form the delivery of the mobile application are located. They are all in the same mobile.zip archive.
We indicate the folder where we installed the Android SDK (you can download it). 1C sets the following requirements:
Android SDK Tools version - no lower than 20.0.3;
Version of Android SDK Platform-tools - not lower than 14;
SDK Platform version - API 8 (not lower than version 8.3).
And we also need a Java SDK (can be obtained at this address) Moreover, 1C warns us that JDK7 does not work in conjunction with the Android SDK.
We indicate the folders where our .apk file will be placed, the location of the signing key and an alias with a password. If you are doing this for the first time and you do not have a key, then you can fill in the “key parameters” and create a key for yourself (in this case, in the “key file” field you must indicate the folder where this key will be created).
Click “OK” and go to the second window.

In it, first of all, we indicate “Mobile application configuration” - the same file that we saved. Then the language, and only then click on the button with a “magnifying glass” and enter the representation there. We indicate “Application ID” - a unique name of the Java class that will be used in the future to perform the update. The identifier must be written in Latin, and 1C recommends starting its name with “com.e1c.” Fill in the version and build number and click the “Create” button. If everything goes well, the system will notify you that the .apk file has been successfully created.
We upload the resulting file to the phone and install it with our favorite manager, having previously allowed the installation of third-party applications in the system settings. Or install the program on the emulator via adb. I’ll say right away: on the emulator everything is terribly slow, but on the phone (I only tested it on the HTC Wildfire S) things are much better, but there are still problems. For example, my file turned out to weigh as much as 34 Mb, so the installation took quite a long time. After launch, we are greeted by a splash screen, and after a while the configuration itself starts. (sorry about the photo: I took it with a calculator)

So far, the new features look very “crude”: limited functionality of 1C, the inability to use the SDK directly, plus a large size and some “brakes”... But the very possibility of writing a program for a mobile platform on 1C is a little surprising! Personally, I'm of two minds about this. On the one hand, this “feature” is still more like a toy, because there is no opportunity to do something truly worthwhile. But on the other hand, this is clearly a big step by the 1C company towards mobility, and if this direction is actively developed, it can bring a lot of benefits. As an example, you can equip storekeepers with tablets. If it is possible to use “on-board” cameras, then you can free yourself from reading devices, and scan codes directly from the tablet, you can provide them to car drivers, and send transportation tasks or track the vehicle’s route and time in motion. In general, there are many options, and the fact that it will all be in a single information system will greatly please customers/managers, because for some reason they always have a panic fear of using a large number of different systems, they want to use all the functionality on single platform.

Somehow quietly and without any special descriptions of the work, 1C released the “Mobile Application Collector” configuration, which is intended to become a kind of organizer for the development of mobile applications.

In the current latest version 1.0.3.17 there are several minor problems that at first glance look like bugs.

The first problem we encounter is the impossibility of launching the configuration without a user, we get the following error:

“The configuration version is different from the infobase version. It is necessary to update the configuration by running the application solution as a user with Administrator rights.

This problem can be solved quite simply; you just need to launch the configurator and add a user with “Administrator” rights.

The second problem occurs when we try to create an element in the “Mobile Configurations” directory. We click the “Create” button and get the error “Items can only be created in groups”:

No problem, we click the “Create Group” button and suddenly again we receive the error message “Items can only be created in groups.”

The solution is to do the following:

On the top panel there is a “Create” button that brings up a submenu. In it, click on the “Mobile configuration” item:

After which a fairly friendly window opens, in which you can create groups:

There is also a problem when creating a directory item “Mobile applications”, we receive the following error message:

"The application ID prefix is ​​not set in the provider settings":

The exit is also quite close:

And we begin to enter data into the “Mobile Solution Providers” directory element.

The prefix must have a “dot” inside. And click “Create developer key”.

This article is for those who are interested in the mobile client. We will look at installing a mobile client on Android, connecting debugging and assembling an apk application in the “Mobile Application Builder” configuration.

Finally, the test mobile platform 8.3.12 has appeared, and now we can test the operation of the mobile client. I don’t know about you, but many developers I know have been waiting for this since the publication of the article on “1C: Through the Looking Glass” (Mobile client).

I assume that you are familiar with installing a mobile application and the mobile application builder, and also that you already have Android SDK, Apache Ant, etc. installed. There are already plenty of articles on this topic.

For our experiments, let’s take the “Managed Application” demo configuration and, first, let’s try to connect it to a ready-made mobile client. In my case, the client distribution is the file “1cem-client-arm.apk”. The ability to install applications from unknown sources must first be enabled on your smartphone. For me it looks like this:

The mobile client is an analogue of the web client, therefore, to access the database, it must be published on the web server. Everything is standard here, I publish to an IIS web server named “demo”. My database is file-based, so I need to give rights to the directory to the IUSR user. I'm glad that the system itself reminded me of this.

Connect the database in the mobile client:

Of course, it was not possible to enter the database right away. The whole point is that the Administrator opens processing for working with email and tries to set an icon for the taskbar, which is not present in the mobile client. Since this functionality is also not available in the web client, the code is framed in compilation directives “#If Not WebClient Then”. We just need to find all the places where this directive is used and change it to “#If Not WebClient AND Not MobileClient Then”. For starters, this is quite enough, and we can finally see the mobile client working. The command interface looks like this:

Here is the list of counterparties:

Of course, these are not all the places that need to be adapted for the mobile client. You can check the configuration using “Main menu - Configuration - ---Check configuration”:

I found 84 errors, including unsupported metadata objects. Plus those three places in the code that I have already limited with directives. So you still have to work on adaptation, but this is certainly not the same as writing a mobile application from scratch.

Launching under other roles occurs the same way, you just need to set the right to launch the mobile client.

If we don’t understand what the error is, debugging will help us. It is available in the mobile client, but only HTTP debugging is used. I have a file database, so I will use the local debugging server (“Tools - Options - Debugging”) and set up an automatic connection for the mobile client (“Debugging - Connection - Automatic connection”):

Specify the parameters and you're done:

The setup for the pre-prepared apk client from 1C is complete.

Now let's build our apk using the mobile application builder. Frankly, I spent several hours trying to build the application the first time. The assembly proceeded, but an empty list of databases opened.

And so, we have an archive of the mobile version of the platform. We upload it to the “Mobile versions” directory:

In the collector settings, a separate item has appeared for SDK 26 and higher (if you, like me, haven’t updated for a long time, launch the SDK Manager and download new packages):

Next you need to prepare a configuration file. It was with this step that I had problems at the very beginning. Then I opened the documentation and everything became a little clearer. The developer's guide says the following about this: "Each configuration that can work in the mobile client contains some auxiliary information that allows you to track the configuration substitution."
The configuration file must be signed. In this case, for each configuration its own private key is generated, and the public key (DSAKey field) is uploaded to the 1cemca.xml file, with which the configuration signature is compared.

To generate a key and signature, go to the properties of the “Mobile client signature” configuration (immediately under the required permissions, if your properties are divided by category and not alphabetically) and see the signature settings:

First, we create a private key and hide it from spies and enemies. Next, we create a configuration signature. For the future, the manual advises going to “Main Menu - Configuration - Mobile Client - Setting up the use of the mobile client.” In the dialog, select the “Verify mobile client signature when updating the database configuration” checkbox and click the “OK” button. Judging by the manual, the signature will change if we change the composition or names of metadata object types, as well as the names and/or composition of register entry keys. Those. changing the forms definitely does not affect the signature and, judging by the description, changing the composition of the details of existing directories and documents (but this is not certain).

The signature is ready, we can continue. Let me tell you right away that background processes are not available in the mobile client, so they need to be disabled in the mobile client permissions. File sharing from a PC is also not available. I additionally disabled geopositioning so that during assembly there would be no error due to the lack of a key for working with maps. I ended up with the following list of permissions:

An example of developing a mobile application in 1C:Enterprise 8.3 for the work of an online store courier when delivering goods to customers. The "Mobile Application Builder" configuration was used for development.

An example of developing a mobile application for an online store courier using the "Mobile Application Builder"

So, we have developed a mobile application for the work of an online store courier when delivering goods to customers. Of course, it is quite schematic and cannot cover all the tasks that actually arise during the work of a courier. But it implements all the functionality that we wanted to show in this book.

Now, after the development is completed, all we have to do is assemble our mobile application into one file and download it to the tablet.

Although we will use a special configuration for assembly Mobile Application Builder, which facilitates the assembly process, is still not easy or quick to do for the first time. Therefore, you need to be patient and carefully and carefully follow the sequence of actions described below.


Where to download and how to install Mobile Application Builder

Configuration Mobile Application Builder supplied as part of the mobile platform. In the first chapter of the book in the section “Mobile platform 1C: Enterprise” we unpacked the archive with the mobile platform onto the computer. In this directory there is a MobileAppMaker folder with a Setup.exe file for installing the configuration template. Let’s run this file and install the configuration template into the “1C:Enterprise” templates directory (Fig. 5.1).

Rice. 5.1. Installing the Mobile Application Builder configuration template

Then we will add a new information base to the list of information bases “1C:Enterprise” and create an information base from the previously created template (Fig. 5.2).

Rice. 5.2. Creating the “Mobile Application Builder” information base from a template

Then we will open this database in the configurator and add the Administrator user with the 1C:Enterprise Authentication properties, the Administrator and User roles and the Russian language (Fig. 5.3).

Rice. 5.3. Creating the "Administrator" user

Let's save the configuration, close it and open it in 1C:Enterprise mode as the Administrator user. Now this database is empty. We must fill it with all the necessary parameters for the assembly, which will be saved and used for further assemblies.

First (if the database is empty), general help information about the mobile application builder opens on the application's initial page. You can also access it from the main menu – Main Menu > Help > Help Contents > Mobile Application Builder. In addition, additional help pages about assembling mobile applications are opened from individual configuration forms (Fig. 5.4).

Rice. 5.4. Mobile Application Builder configuration help


Configuring Application Solution Parameters

First we have to configure the collector settings. To do this, from the Tools menu, call the Application Settings item. We will not be building a mobile application for Apple now, so we will leave the corresponding checkbox empty.

In the settings form, we need to fill out the table Component directories on computers participating in the build process, which will contain the paths to the software components necessary to build the mobile application. To do this, click the Create button above this table (Fig. 5.5).

Rice. 5.5. Creating a table entry “Component catalogs...”

The Component Paths form will open. By calling help from this form, you can see links to obtain software components and their descriptions (Fig. 5.6).

Rice. 5.6. Help describing paths to components

First you need to install the Java SDK and in the JDK field indicate the directory in which this component is installed. The Java SDK can be obtained from: http://www.oracle.com/technetwork/java/javase/downloads/index.html. It is recommended to download the Java Platform Package (JDK).

On the page that opens, at the top you need to click on the Download button (Fig. 5.7).

Rice. 5.7. Getting the Java SDK

On the next page you need to accept the license agreement (check the Accept License Agreement box) and click on the link with the desired distribution in the Download column (for 64-bit Windows - this is the package jdk-8u60-windows-x64.exe), fig. 5.8.

Rice. 5.8. Getting the Java SDK

The resulting installer needs to be launched and the Java SDK installed, for example, in the directory: C:\Program Files\Java\jdk1.8.0_60 (Fig. 5.9).

Rice. 5.9. Installing Java SDK

Then this path must be specified in the JDK field of the form for setting paths to the components of the Mobile Application Builder application (Fig. 5.10).

Rice. 5.10. Configuring paths to components of the Mobile Application Builder application

In the next field of the configuration form, Working directory and builder cache, you need to specify any directory in Latin in which the build program will place service files. The user on whose behalf the mobile applications will be built must have full rights for this directory (Fig. 5.11).

Rice. 5.11. Configuring paths to components of the Mobile Application Builder application

In the Android SDK field, specify the path to the directory where the SDK Manager is located. We installed the Android SDK in Chapter 1, in the “Android SDK” section (Fig. 5.12).

Rice. 5.12. Configuring paths to components of the Mobile Application Builder application

Then you need to install Apache ANT and in the Apache ANT field specify the directory in which this component is installed. Apache ANT is required to build a mobile application for Android OS. Apache Ant can be obtained.

From this page we need to download the apache-ant-1.9.6-bin.zip archive (Fig. 5.13).

Rice. 5.13. Getting Apache ANT

Unzip this file to your computer and specify the path to it in the form of setting paths to components (Fig. 5.14).

Rice. 5.14. Configuring paths to components of the Mobile Application Builder application

Then you need to install the PuTTY system and in the PuTTY field specify the directory in which this component is installed. PuTTY can be obtained.

PuTTY is used if you are building a mobile application for Apple. To build mobile applications, the pscp.exe and plink.exe utilities are required. Just in case, let’s download the entire installation package putty-0.65-installer.exe (Fig. 5.15).

Rice. 5.15. Getting PuTTY

The resulting installer needs to be launched and PuTTY installed, for example, in the directory: C:\Program Files (x86)\PuTTY (Fig. 5.16).

Rice. 5.16. Installing PuTTY

Then we indicate the path obtained when installing PuTTY in the form for setting paths to components (Fig. 5.17).

Rice. 5.17. Configuring paths to components of the Mobile Application Builder application

This completes the configuration of paths to components. Click Record and close.


Configuring Provider Options

Now we need to configure the provider settings. To do this, call the Edit supplier parameters item from the Tools menu.

The Suppliers form will open, in which you need to specify an arbitrary name of the supplier on the General parameters tab, and also set the Application ID Prefix. This field must be filled out in Latin and begin with the line “com”. The rules for filling out this field can be found in the contextual help, which can be opened by clicking the button with the “?” sign.

Then you need to note for which operating systems the mobile application is being built. In our case, select the For Android OS checkbox.

To work with push notifications through the auxiliary service “1C:Enterprise” we will specify the parameters for accessing the service. To do this, click the Add button above the table at the bottom of the supplier form. In the window that opens, Settings for access to the auxiliary service “1C:Enterprise”, check the Register for – selected user option, select the collector user – Administrator and indicate the email address and password under which we previously registered on the service when testing work with push notifications. Click the Save and Close button. In addition, you can register for the 1C:Enterprise service directly from this form using the Register in the 1C:Enterprise service button, if this has not already been done (Fig. 5.18).

Rice. 5.18. Configure Mobile App Builder app provider settings

In addition, you can call the window for setting parameters for access to the 1C:Enterprise service from the Tools menu, item Access parameters for the 1C:Enterprise service.

After this, you need to fill in the Developer Key group of fields on the Settings for Android OS tab. To do this, first create a developer key by clicking on the Create a developer key link. In the Create a developer key form that opens, fill in the fields randomly (for the Country field you need to specify the code of Russia in the ISO standard - ru) and click the Generate key button (Fig. 5.19).

Rice. 5.19. Configure Mobile App Builder app provider settings

After this, the developer key parameter fields will be filled in automatically (Fig. 5.20).

Rice. 5.20. Configure Mobile App Builder app provider settings

The value in the SHA1 Hash field of the developer key will be used in the future to obtain the key for working with Google maps. This value is required if the mobile application will use geolocation tools on the Android platform.

This completes the configuration of the supplier parameters. Click Record and close.


Loading the mobile platform

Now we need to download the 1C:Enterprise mobile platform, under which the assembled mobile application will run. There may be several versions of the mobile platform, but they must be no lower than version 8.3.4.

The Mobile Platforms directory is intended for downloading and storing different versions of the mobile platform. A separate entry must be created for each platform version in this directory.

From the application command panel, open the Mobile platforms directory and click the Create button. After this, a file selection dialog will appear in which you need to select the file with the archive of the mobile platform mobile.zip, which we saved on the computer when receiving the mobile platform in the first chapter of the book, in the section “Mobile platform 1C: Enterprise”. Select it and click the Open button.

If the platform is successfully loaded, the form for creating a directory item Mobile platforms will open, in which the Mobile platform version and Name fields will be filled in automatically, and the Mobile platform files loaded checkbox will appear (Fig. 5.21).

Click Record and close.


Loading mobile configuration

Now we need to load the mobile configuration of the Courier Online Store that we have developed. Let's open this configuration in the configurator. In the configuration properties palette, set the properties Vendor – myfirm and Version – 1.0.0 (Fig. 5.22).

Rice. 5.22. Properties of the mobile configuration of “Courier Online Store”

Then we will upload this configuration to a file by executing the configurator command Configuration > Mobile application > Write to file...

The Mobile Configurations reference book is used to download and store different versions of mobile application configurations. The directory assumes a two-level structure: groups describe application solutions, and elements in the groups represent different versions of the configurations of these application solutions. To download a new version of the configuration, you need to go to the group corresponding to the application solution and create a new element in this group.

From the command panel of the application, open the Mobile Configurations directory and click the Create group button with the name of our configuration Online Store Courier (Fig. 5.23).

Rice. 5.23. Creating a directory group "Mobile configurations"

Then in this group we will create a new directory element.

After this, a file selection dialog will appear in which you need to select the 1cema.xml file into which we just saved our mobile configuration. Select it and click the Open button.

If the configuration is successfully loaded, all form fields will be filled in automatically and should not be changed manually. The permissions table will indicate all the permissions for the mobile application to work with multimedia, geopositioning, notifications, etc., which we set during its development. In addition, messages will be displayed about the impossibility of working with calendars and contacts, permissions for which we did not set (Fig. 5.24).


Click Record and close.


Description of mobile application parameters

Now we need to describe the parameters of the mobile application that we will collect in the Mobile Applications reference book.

The reference book should have a two-level structure, where the group describes the main assembly parameters, and the group element specifies the assembly parameters for a specific version of the mobile application. A separate group must be created for each mobile application, and for each version of the mobile application in this group you must create its own element.

From the application command panel, open the Mobile Applications directory and click the Create group button. In the form that opens, set the name of the mobile application Courier Online Store.

We have one supplier - My company. It will fill in automatically. The For Android OS checkbox will also be selected. Leave the Mobile platform field empty - the latest version of the platform will be automatically used during assembly.

In the Solution ID field, enter an arbitrary string in Latin. The next field will be filled in automatically (Fig. 5.25).

Rice. 5.25. Creating a directory group “Mobile applications”

After this, the Parameter for obtaining a key for working with Google maps field will be automatically filled in (the value of the parameter Hash SHA1 of the vendor developer key My Company from the supplier settings form is inserted into this field, see Fig. 5.20 + solution identifier line) - we will need this to obtain the key for working with Google maps. To do this, we must contact the Google service and, after receiving the key, write it in the Key for working with Google maps field.