开发者

How to have both Debug and Release apk on same device?

开发者 https://www.devze.com 2023-04-03 11:02 出处:网络
While continuing to develop my application and test it on a real phone, I need to have the release version of it on the same phone, for demonstration purposes (the release version is much more respons

While continuing to develop my application and test it on a real phone, I need to have the release version of it on the same phone, for demonstration purposes (the release version is much more responsive, thanks to no-logs).

The problem is that the only way to make two applications co-exist on the same device in Android is by having different package names.

But package names require re-factoring and lots of propagating manual fixes... not to mention that this confuses version c开发者_JS百科ontrol...

Ideally, Eclipse+ADT would allow appending a modifier variable that would automatically generate a different package name for debug/release and would allow such co-existence, but I couldn't find any mechanism that allows doing that.

Do you know of any way to workaround this?

Creative solutions and ideas are welcome.


Use Android Studio because gradle make your life a lot easier - just use applicationIdSuffix

android {  
   ...  
   buildTypes {  
     release {...}  
     debug {  
       applicationIdSuffix '.debug' 
     }  
   }  
}

For more go here.


The only way I know is to change the package name in your applications manifest file. Eclipse should handle all the code renaming for you.


Could you put all your code in a Library Project and then just have two normal projects, that have different package names and just include the library project in both?

This should keep all your code in one place. The normal projects would most likely only need a valid manifest file that points to the activities in the library project.


You may want to try this technique using ant, Jenkins and perhaps other tools to automate package renames as suggested by @LAS_VEGAS.

Although not what you asked for, this cool code snippet can help you find out at runtime whether your code is debug or release.

Another interesting such attempt can be found in this thread. I am not sure though if it works on Android.


In Android Studio, Adding build variants using Product Flavours which can be easily customized for various environments and to test side by side multiple app variants of same app. Check out this link for more information - Configuring Gradle

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号