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].
For more options, visit https://groups.google.com/d/optout.