Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - testing vs. production version

Tags:

android

build

I am facing problem. I need to build one app in two ways, first build is for development (testing) use, second build should be production version. Are there any ways how to do it programatically? (with some build engines) I mean that both apps shloud run on one device at the same time if possible. Both version are APK from one Android project.

Thanks

like image 699
Waypoint Avatar asked Sep 15 '11 08:09

Waypoint


People also ask

What is production version of an app?

RELATED APPS. More. A production version is the link between the bill of material (BOM) of a product and the process of routing. It determines which BOM relates to the relevant routing to produce a material or plan a material. There may be different production versions based on the lot sizes and validity dates.

What is Android testing?

Testing is an integral part of the app development process. By running tests against your app consistently, you can verify your app's correctness, functional behavior, and usability before you release it publicly. You can manually test your app by navigating through it.

What is Versioncode and Versionname in Android?

The version code is an incremental integer value that represents the version of the application code. The version name is a string value that represents the “friendly” version name displayed to the users.

Which version is best for Android studio?

Android Studio 3.2 is the best way for app developers to cut into the latest Android 9 Pie release and build the new Android App bundle.


2 Answers

Personally I use this to determine whether I am in debugging mode:

final PackageInfo pinfo = getPackageInfo(ctx);
final boolean debugMode = (pinfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;

This code is based on the debuggable attribute of the Application tag of the android-manifest.xml:

  • If this attribute is explicitely set to true debugMode will be set to true.

  • But if it is explicitely set to false or not present in the xml (implicit values), debugMode will be set to false.

Doing this way you cannot run both app on the same device at the same time as two APK need two different package name to be installed concurrently. So you have to build two eclipse projects, each one having its own package name (for example com.example.myapp.debug and com.example.myapp), and why not using a common lib (com.example.myapp.common) that would contain almost all your code:

  • com.example.myapp.debug has its debuggable flag set to true

  • and com.example.myapp has its debuggable flag set to false

like image 72
Shlublu Avatar answered Nov 15 '22 18:11

Shlublu


As far as I see, you really need to create different applications from you base code. One way to get this done, as I did it, is to use Ant script that copies the entire project source into another directory, say "testing", and while doing so, replaces (e.g. using copy filtering) certain values from XML files, like from AndroidManifest.xml. One of the first things to replace is applications package that needs to be unique for each app. The Java classes like Activities can still reside in the original packages, their names in AndroidManifest.xml just need to be absolute. Once source has been copied and filtered, you can use Ant's antcall task from the main build.xml to build the customized app. So at the end, you can say e.g.: "ant -Denv=testing build" and you have an APK that can be installed next to your production version.

Another alternative is to use Maven that's Android plugins support project overlaying. And of course you can use library projects, see: Android – multiple custom versions of the same app.

like image 37
jraanamo Avatar answered Nov 15 '22 17:11

jraanamo