ant - Custom build Android app from command line -


i'm trying make batch file commands, once runs, change strings in files, build project , generate apk signed. strings need change are: - package name (com.company.project) - images (like icons, splash screen, ...) - irrelevant string specific app.

for last 2 things know how it, package name feel there wrong find , replace occurrences of string in root folder of app (including subdirectories).

is there way or command ant has doing this?

also ran issue while running command ant release. went root folder, ran command , gets errors. had go eclipse, clean project , let autobuild (with no generation of apk since when try run on device) @ point bin folder contains folders: classes, dexedlibs, res , manifest.xml file.

then can go cl , run ant release. there way cl? clean , build can run ant release command after no issues?

note: find , replace use .exe called fnr job

edit: i'm using gradle , can build changing package name there still few things want in build.gradle file , can't make work.

this build.gradle:

task("hello"){   println "hello world!!" } buildscript {     repositories {         mavencentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:0.8.+'     } } apply plugin: 'android'  dependencies {     compile filetree(dir: 'libs', include: '*.jar') }  android {     compilesdkversion 19     buildtoolsversion "19.0.3"          productflavors {         flavor1 {             packagename "com.testcompany.testproject"         }     }      signingconfigs {           release {               storefile file("keystore/android.keystore")               storepassword 'blah blah'               keyalias "blah blah"               keypassword 'blah blah blah'          }      }       buildtypes {         flavor1 {             zipalign true             sourcesets {                 main {             signingconfig signingconfigs.release                     manifest.srcfile 'androidmanifest.xml'                     java.srcdirs = ['src']                     resources.srcdirs = ['src']                     aidl.srcdirs = ['src']                     renderscript.srcdirs = ['src']                     res.srcdirs = ['res']                     assets.srcdirs = ['assets']                 }             }         }      } } 

i pretty sure i'm doing things wrong. want to: - change strings in res/strings.xml file. - change icon/png files in res/drawable.... folder custom ones.

i have no idea of how it. tried:

buildtypes{     flavor1{         copy{             from('src/res/'){              include '**/*.xml'              filter{string line -> line.replaceall(string_to_be_replaced, replaced_string)}             }             '$builddir/res'         }     } }  

but nothing

the strings need change are: - package name (com.company.project)

if changing these things based upon whether debug build or release build, can specify suffix on package name build type:

android {     buildtypes {         debug {             packagenamesuffix ".debug"         }     } } 

or, if changing these things else, can create product flavors , replace package name per flavor:

android {     productflavors {         flavor1 {             packagename "com.example.flavor1"         }          flavor2 {             packagename "com.example.flavor2"         }     } } 
  • some images (like icons, splash screen, ...) - irrelevant string specific app.

you can create source sets build types (e.g., src/debug/) or product flavors (e.g., src/flavor1/) , have replacement versions of resources in them. handle images, "irrelevant string" if define string resource.

source sets can have java code, though gets incrementally more complex, recommend use string resources , replacement resources instead.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -