Hey Xavier-

The manifest in the test folder doesn't pass along any values for 
versionCode and versionName. In my use case, it'd be nice to have them flow 
through to the test project as I've got some device reporting code that I'm 
testing which is polling the application for it's versionCode and 
versionName and I'd like to be able to confirm via unit test that it works.

Whatever you guys decide, the BuildConfig should probably line up with the 
manifest if for no other reason than to make the debugging quest a bit 
easier for people like me in the future.

-Bill

On Wednesday, April 23, 2014 7:38:29 PM UTC-4, Xavier Ducrohet wrote:
>
> You could look at the generated manifest for the test app (under 
> build/manifest/test/...) but it looks like it could be inconsistent with 
> BuildConfig.
>
> Clearly the versionName/Code doesn't really means anything for the test 
> app since it's not published. That's why we didn't set those values in the 
> test manifest. They probably shouldn't be in BuildConfig either.
>
>
> On Wed, Apr 23, 2014 at 2:11 PM, Bill Magnuson 
> <[email protected]<javascript:>
> > wrote:
>
>> Greetings-
>>
>> I had a few unit tests that started failing after my migration to the new 
>> build system. I just wanted to check in and see if the behavior I'm seeing 
>> for grabbing version codes and names in test projects is expected.
>>
>> I've setup an 'android-library' project with the conventional folder 
>> structure. What I'm seeing is that the versionCode and versionName that I 
>> include in the android.defaultConfig (or even in the AndroidManifest.xml 
>> itself) appear to be totally ignored when the test APK runs.
>>
>> For example, if I run the following in a test (where 
>> mContext.getPackageName() is returning the value of my test package), I get 
>> 0 for the versionCode and null for the versionName.
>>
>>          PackageInfo packageInfo = 
>> mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
>>         versionCode = packageInfo.versionCode;
>>         versionName = packageInfo.versionName;
>>
>> I've set them in my defaultConfig as here:
>>
>> android {
>>   compileSdkVersion 19
>>   buildToolsVersion '19.0.3'
>>
>>   defaultConfig {
>>     minSdkVersion 8
>>     targetSdkVersion 19
>>     testInstrumentationRunner "android.test.InstrumentationTestRunner"
>>     versionCode 2
>>     versionName "1.1"
>>   }
>>
>>   publishNonDefault true
>> }
>>
>> The generated BuildConfig in 
>> build/source/buildConfig/test/debug/com.appboy.test/BuildConfig.java looks 
>> good:
>>
>> public final class BuildConfig {
>>   public static final boolean DEBUG = Boolean.parseBoolean("true");
>>   public static final String PACKAGE_NAME = "com.appboy.test";
>>   public static final String BUILD_TYPE = "debug";
>>   public static final String FLAVOR = "";
>>   public static final int VERSION_CODE = 2;
>>   public static final String VERSION_NAME = "1.1";
>> }
>>
>>
>> I'm just going to change the tests for now, but thanks in advance for any 
>> thoughts.
>>
>> -Bill
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "adt-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Xavier Ducrohet
> Android SDK Tech Lead
> Google Inc.
> http://developer.android.com | http://tools.android.com
>
> Please do not send me questions directly. Thanks! 
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to