EMDK with multiple product flavors & different application ids

When using Android Studio 3.0 with one product flavor and two build types (release & debug) the emdk works as intended.  I have the EMDKConfig.xml file in /assets folder and everything syncs up nicely.  The problem comes in when I have different build flavors that change the application id, the use case for this is to provide my testers with a test version of the app along side the production version, so i will have two product flavors, prod & qa.  The qa build flavor uses an appendix to the the application id, "com.example.app.qa".  When I do this the broadcast for the scanner is not being received in my app, however the initialization of the emdk does not fail, it still returns successfully.

 

Here is an example of my product flavors

 

productFlavors {

  prod {

  resValue 'string', 'app_name', "Application"
  }

  qa {

   applicationIdSuffix ".qa"
   resValue 'string', 'app_name', "Application-QA"
  }

}

 

Any ideas why changing the application id breaks the scanning?

 

p.s. - Device is TC70 with Android 4.4

Anonymous (not verified)
Hi Joseph,I wrote a blog

Hi Joseph,

I wrote a blog about using different flavours with the EMDK: Deploying an application to Zebra Android devices ranging from Jellybean to Marshmallow and beyond – DARRYN CAMPBELL BLO…  , in it I discuss using different source sets for the different EMDK XMLs.  It has been nearly a year since I wrote the blog and I have not looked at it since so my memory is a bit rusty but hopefully that helps.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charles Berlin
Very informative blog post,

Very informative blog post, well written.  Unfortunately it does not address my specific issue.  If I simply use different build flavors, everything still works correctly, what seems to cause the issue is changing the application id.  In my gradle example above, if I comment out "applicationIdSuffix ".qa"" then there is no issue.  But what i need is for the qa flavor to have a different application id.  Any ideas on why the application Id changing causes the scanner to fail?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charles Berlin
On further inspection, I don

On further inspection, I don't think this is related to build flavors/variants at all.  If I simply go into my gradle file and change the application id, the scanner intent is not captured by my app. 

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
It sounds like you are

It sounds like you are probably using a DataCapture Profile.  If so,  there is a place in the EMDKConfig.xml to define what Application and Activity the profile is linked to.

Activity Selection Profile Feature Reference - Zebra Technologies TechDocs

If you are changing the application ID without changing the Profile to match,  the scanner would not work properly.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charles Berlin
I have this section in my

I have this section in my EMDKConfig.xml

<characteristic type="ActivitySelection" version="0.1">
  <parm name="emdk_name" value="Main"/>
  <characteristic type="Application">

  <parm name="PrefixAppName" value="true"/>

  <parm name="package" value="com.example.application"/>
  <characteristic type="Activities">\
  <parm name="activity" value="MainActivity"/>
  </characteristic>
  </characteristic>
  </characteristic>

Again this works fine until I change the application id in gradle.  I've tried updating the package line to match the new application id, but that still does not matter.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
The DataCaptureProfile

The DataCaptureProfile functionality creates a DataWedge profile associated with your application.  Can you please check the newly created profile under DataWedge (app) --> Select profile which should share a name with your app --> Associated apps and then see what the value is of the associated app and activity.  Possibly the DataCaptureProfile does not overwrite the associated activity when you change the application ID and you would need to delete the profile manually (as a work around) when switching application types.  So my question is, does it work if you delete the associated DataWedge profile every time you change the application ID?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charles Berlin
Ah ok, thank you for that, I

Ah ok, thank you for that, I would have never thought to look there.  So I think I see what's going on now.  When I Inspect the profile in the datawedge app it assumes that the package and the application id are the same.  So if I change the application id by appending ".qa", the profile assumes that the activities listed are now found in "com.example.application.qa", but they are still at the package "com.example.application".  Is there a way to configure that?

If you can then I can just use separate profiles for each build flavor to solve this problem.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charles Berlin
Also I noticed that the

Also I noticed that the profile manager does not work with Android Studio 3.0.  I tried to reinstall Android Studio 2.3.3 and run the profile manager but was not able to get it to work.  I was looking into this because I noticed there is a wildcard option for activites and thought this might work for what I'm trying to do. However I don't know what the generated xml looks like for that so was wondering if maybe you had any ideas there.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charles Berlin
Ok, I have a working example

Ok, I have a working example now.  I needed to use a wildcard for the activities to get it to work.

Thanks for your help guys

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
That's great.  There is some

That's great.  There is some strangeness with Android Studio 3.0 I think (at least with EMDK 6.6 if you upgrade your IDE).  Rob did a blog about it here:

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments