I have an XML file that contains some config data for my Android App. In it there is config info that can be used for development and production. E.g. the link to our api can be set as follows:
For production:
<api>api.example.com</api>
For development:
<api>dev.example.com</api>
I keep this config file under /assets/app-config.xml
It is quite a hassle to keep having to remember which setting I have in the XML. Is there a way to automatically configure eclipse/ android so that it uses the production for runtime (export etc.) and the development when in debug mode.
Define multiple resources and use BuildConfig.DEBUG to conditionally get a resource or another:
<string name="url_api">api.example.com</string>
<string name="url_api_dev">dev.example.com</string>
When extracting the resource:
getString(BuildConfig.DEBUG ? R.string.url_api_dev : R.string.url_api);
This constant is set to true as long as you run from Eclipse. When you select the Export Signed Application Package option, it will be set to false.
If you use this method, it is a good idea to be aware of this bug.
Customize your build using ANT
Please refer the following link for more information
http://playaprogrammer.blogspot.com/2013/01/android-build-configuration-tutorial.html
I use this to create test and production builds from single source. You can have different configurations for development, QA, Production...
Related
The command line version of apksigner supports the following arguments
--ks-provider-name <name>
--ks-provider-class <class-name>
--ks-provider-arg <value>
Since my company is implementing a custom keystore, I would like to use that option. But I'm wondering if there is any way for me to specify the values of those argument to the signing config block instead?
Based on the following documentation :
https://developer.android.com/reference/tools/gradle-api/4.2/com/android/build/api/dsl/SigningConfig
I can't seem to find the field that I need.
Actually the main goal is I want to integrate the signing process into the gradlew assemble task instead of two seperate processes (build and then sign).
Is there any idea how I can achieve this?
The DSL for the SigningConfig is here : https://developer.android.com/reference/tools/gradle-api/4.2/com/android/build/api/dsl/SigningConfig
As you can see, there is unfortunately no option to provide your own signing provider. File a feature request to the Android Gradle plugin team.
In my Ionic 5 app, I am using the capacitor-community/sqlite plugin. I am successfully able to create and use an encrypted db with this plugin. To use encryption a secret is required and the following is maintained in the official documentation as of today.
Defining your own secret and newsecret keys (encryption only)
in IOS, go to the Pod/Development Pods/capacitor-sqlite/GlobalSQLite.swift file
in Android, go to capacitor-sqlite/java/com.jeep.plugin.capacitor/cdssUtils/GlobalSQLite.java
and update the default values before building your app.
in Electron, go to YOUR_APP/electron/plugins/plugin.js-xxxx.js and search for class GlobalSQLite and modify the this.secretand
this.newsecret parameters.
I have searched for files GlobalSQLite.swift and GlobalSQLite.java in IOS and android respectively but there are no such files present. Also, the file paths are not available. I am not sure how to get these files to set my secret in the app. Please help.
You should look for the GlobalSQLite.java in node_modules\#capacitor-community\sqlite\android\src\main\java\com\getcapacitor\community\database\sqlite\SQLite. After changing the secrets you may need to sync the platforms with ionic cap sync.
The iOS and Electron files you also find there
I have two ane file for video recorder. One is for android and another is for ios device. Both have different package name and methods.
Now, i import both Native Extension in single project. And detect ios and android device following way:
if(Capabilities.version.indexOf('IOS') > -1) //for ios device
And
if(Capabilities.version.indexOf('AND') > -1) //for android device
And create object for each class. Now when i run that it gives error for another ane class not found.
Like Suppose i check in ios then gives error for android ane file class, Event not found. same for android.
If you have an ANE that only supports Android it won't be available at all when run in Ios (same is true for Ios). If it has a default implementation its classes will be available but if it doesn't then its classes will just not exist in that scope and error will be thrown if you try to reference them. When using ANE that only offer one platform implementation those ANE have to be used only when compiling for that platform. The way you can switch between ANEs easily is by using CONFIG constants.
EDIT: Defining constants. Right Click project and choose "properties", in "Actionscript compiler" add as many config lines as you see fit, for example:
-define=CONFIG::ANDROID,false
-define=CONFIG::IOS,false
Now wrap all code (including import statements) referencing the Android ANE and the IOS ANE with:
CONFIG::ANDROID
{
//android code here
}
CONFIG::IOS
{
//ios code here
}
Now your 2 config variables are set to false so no code in between "CONFIG::ANDROID" or "CONFIG::IOS" will be compiled with your app. Now if in "actionscript compiler" you change:
-define=CONFIG::ANDROID,true
All code that is in between "CONFIG::ANDROID" will be compiled (you can use "CONFIG::ANDROID" anywhere in your code as many times as you want).
So before compiling set one config to true and make sure the other is set to false and the right code for the right platform will be compiled.
Capabilities.version will tell you: "Specifies the Flash Player or AdobeĀ® AIRĀ® platform and version information." and not the OS version you are running on.
See here http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#version
You need to use Capabilities.os instead
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#os
I have a Parse account that I'm using to store user data for my Android application. Because I'm using source control, I don't want to leave my secret key embedded in the code. Is there a way to have a "config" file that I would keep out of source control, that can then host the key? If that's not feasible, what are the best practices of handling such a situation?
Yes, you can create a folder outside of source control, put a file called app.properties in there, put your key in that properties file and add the folder to your build path. Then use a properties loader to load it from the classpath.
If you have many developers or more than one dev machine, you can set the local properties location as a variable in your build path so that each developer can configure their own.
One option is to put the key in an environment variable and then read it during your build.
in your pom.xml declare a property (secret.key)
<properties>
<secretKey>${env.SECRET_KEY}</secretKey>
<properties>
further down enable "filtering" on your resources
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
In resources maintain a "config.properties" to read with the variable ready for substitution:
secret_key=${secretKey}
Filtering in maven will replace ${secret.key} with the value from your environment variable.
If you are using gradle for your build with Android studio see section 16.6.6.2 on filtering files.
Within build.gradle add the following
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
task copyProductionConfig(type: Copy) {
from 'source'
include 'config.properties'
into 'build/targetpath/config'
expand([
secretKey: System.getenv("SECRET_KEY")
])
}
In gradle you can also request input when you run gradlew using
Console console = System.console()
def password = console.readPassword("Enter Secret Key: ")
And then apply it to the appropriate config or source files.
i'm trying to get android running on a gumstix overo system.
since i'm not planning to use the final "product" as a phone, i asked my self if it is possible to exclude applications like the phone/dialer-app from the kernel build-process (any config parameter probably?)
Just remove (or comment) these lines:
<project path="packages/apps/Phone" name="platform/packages/apps/Phone" />
<project path="packages/apps/VoiceDialer" name="platform/packages/apps/VoiceDialer" />
(and others if needed) from the platform manifest (default.xml) :
https://android.googlesource.com/platform/manifest/+/master/default.xml
Removing the app declarations in the repo manifest did not work for me, as there are other libraries that reference them that then fail to compile. The build system approach to this problem is to create/modify your product definition makefile to not include the specific apps.
So, for the overo you probably already have a products/overo.mk product file. You can manually set the PRODUCT_PACKAGES variable to which applications you want to ship. You will also want to take a look at the PRODUCT_POLICY variable, as it defines sets of applications for your product type.
It can take some fiddling to get everything to build correctly, due to interdependencies between applications, but the Android build output does a pretty good job of explaining the problems when they arise.