Changing application package name in custom Ant build step

This is the way I do it (working) <target name=”-package-resources” depends=”-crunch” > <!– only package resources if *not* a library project –> <echo message=”Current Package name: ${app.custompackagename}” /> <do-only-if-not-library elseText=”Library project: do not package resources…” > <aapt androidjar=”${project.target.android.jar}” apkfolder=”${out.absolute.dir}” assets=”${asset.absolute.dir}” buildType=”${build.target}” command=”package” debug=”${build.is.packaging.debug}” executable=”${aapt}” ignoreAssets=”${aapt.ignore.assets}” libraryPackagesRefid=”project.library.packages” libraryRFileRefid=”project.library.bin.r.file.path” libraryResFolderPathRefid=”project.library.res.folder.path” manifest=”${out.manifest.abs.file}” manifestpackage=”${app.custompackagename}” nocrunch=”${build.packaging.nocrunch}” previousBuildType=”${build.last.target}” resourcefilename=”${resource.package.file.name}” resourcefilter=”${aapt.resource.filter}” versioncode=”${version.code}” … Read more

Gradle finished with non-zero exit value 1 (ic_launcher.png: error: Duplicate file)

According to Xavier Durochet’s explanation on G+, it’s due to one of the libraries you use having it’s own ic_launcher.png — which they of course should not (more on that at the bottom). Chances are the two icons mentioned in the log are different: one is yours and another one is most likely the generic … Read more

Android – Inner element must either be a resource reference or empty

When declaring id in resources, the body should be empty <item type=”id” name=”id_name” /> For more info please have a look on below link https://developer.android.com/guide/topics/resources/more-resources#Id So as Oliver Manyasa mentioned, it should be as below <?xml version=”1.0″ encoding=”utf-8″?> <resources> <item name=”tv_deviceName” type=”id”/> </resources>

Android Studio 3.0 Manifest Error: unknown element found

You have a misplaced tag. The new AAPT (AAPT2) now throws an error on this. From the docs in here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html Behavior changes when using AAPT2 To improve incremental resource processing, Android plugin 3.0.0 enables AAPT2 by default. Although AAPT2 should immediately work with older projects, this section describes some behavior changes that you should … Read more

Programmatically change the value of a color resource obtained from API response

You can create a class which extends Resources and override the methods getColor(int) and getColor(int, Theme). Example: colors.xml <?xml version=”1.0″ encoding=”utf-8″?> <resources> <color name=”your_special_color”>#FF0099CC</color> </resources> Res.java public class Res extends Resources { public Res(Resources original) { super(original.getAssets(), original.getDisplayMetrics(), original.getConfiguration()); } @Override public int getColor(int id) throws NotFoundException { return getColor(id, null); } @Override public int … Read more