I am using Here maps Premium SDK 3.15 and in the documentation, it says to set id, token, and license in the android manifest file. I set id, token, and license in build.gradle as a manifest placeholder and put in Android.manifest like below.
<!-- Here Maps -->
<meta-data android:name="com.here.android.maps.appid"
android:value="${here_map_app_id}"/>
<meta-data android:name="com.here.android.maps.apptoken"
android:value="${here_map_app_code}"/>
<meta-data android:name="com.here.android.maps.license.key"
android:value="${here_map_licence_key}"/>
My project run into static code analysis and one of the finding is "Hard-Coded Secret Tokens Present in Application Code". It means I keep the here map credentials in build.gradle and it's not ok.
My question is where should I keep these credentials and is there a way setup Here maps SDK programmatically instead of Android. manifest (In case, I do not keep in the project and retrieve from Backend)
No you cannot programmatically alter the manifest file or resources except by gradle injection. According to Here maps : https://developer.here.com/documentation/android-premium/3.15/dev_guide/topics/credentials.html there is only one way to set the credentials ,however you can take some security measures see https://stackoverflow.com/a/46475968/8461344
You can use manifest placeholders:
https://developer.android.com/studio/build/manifest-build-variables
and then place your keys in env or local.properties like below
(build.gradle)
manifestPlaceholders = [
HERE_SDK_APP_ID : System.getenv("HERE_SDK_APP_ID") ?: "APP_ID",
HERE_SDK_APP_TOKEN : System.getenv("HERE_SDK_APP_TOKEN") ?: "APP_TOKEN",
HERE_SDK_LICENSE_KEY: System.getenv("HERE_SDK_LICENSE_KEY") ?: "APP_LICENSE",
]
and in AndroidManifest.xml:
<meta-data
android:name="com.here.android.maps.appid"
android:value="${HERE_SDK_APP_ID}" />
<meta-data
android:name="com.here.android.maps.apptoken"
android:value="${HERE_SDK_APP_TOKEN}" />
<meta-data
android:name="com.here.android.maps.license.key"
android:value="${HERE_SDK_LICENSE_KEY}" />
I think this has been already answered here Dynamic API KEY for Google Maps on Android
It is clear that google maps don't support dynamic API key insertion.
For any other dynamic API Keys, Where you don't want to hardcode in the project, you can check out Firebase RemoteConfig.
Here is the link,
https://firebase.google.com/docs/remote-config/use-config-android
Related
My account status for here map is freemium but i have generated APP_CODE and APP_ID successfully but getting Incorrect application credentials when loading app please help.
For mobile maps you need app id, code and license key. Please follow instructions in https://github.com/heremaps/here-android-sdk-examples/blob/master/README.md to launch your app. Check if you have provided the below details in AndroidManifest.xml file. Also check if the package name provided both while generating credentials and your project matches exactly.
<meta-data android:name="com.here.android.maps.appid" android:value="{YOUR_APP_ID}"/>
<meta-data android:name="com.here.android.maps.apptoken" android:value="{YOUR_APP_CODE}"/>
<meta-data android:name="com.here.android.maps.license.key" android:value="{YOUR_LICENSE_KEY}"/>
I have an application with some separated modules.
In addition, I want to use a different fabric users (api keys) for each module.
When I try to register another module with the fabric key in the manifest, like this:
<meta-data
android:name="io.fabric.ApiKey"
android:value="My_Key" />
I get an error of duplicated apikey.
Is there any option to implement this?
Using Unity and CloudOnce,
I am implemeting cloudonce in my app withouth successfull, so I started a new project , just added the cloudonce and set up it correctly,
but it crashed, After look up in the logs on logcats the error was
"Using Google Play games services requires a metadata tag with the
name "com.google.android.gms.games.APP_ID" in the application tag of
the manifest for com.xxx.xxx"
after further look in the manifest, I miss this
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
After look in the Plugins/Android/AndroidManifest there is no meta data with the app id either
You can either run the Android setup from the Unity Menu or invoke it statically with the correct values. If you just want to add the app id property to the AndroidManifest.xml, you can escape it with a space to force the parser to interpret the app id as a string. This is what the plugin does when you run setup.
For example:
<!-- The space in these forces it to be interpreted as a string vs. int -->
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="\ 1213456789" />
I have setup Facebook sharing with the below, build type specific content provider:
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProviderXXX${applicationId} ...
applicationId is different per build type, so that I am able to run debug and live builds side by side on one device.
This setup gives me an error on Facebook (image file) sharing:
IllegalStateException: A ContentProvider for this app was not set up in the AndroidManifest.xml, please add com.facebook.app.FacebookContentProviderXXX as a provider to your AndroidManifest.xml file. See https://developers.facebook.com/docs/sharing/android for more info.
How can I overcome this problem? How can I get Facebook to take into account my applicationId?
You Manifest code look like below for facebook login and sharing:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/{facebook_app_id}" />
<!-- To use Facebook Login or Share, also add the FacebookActivity to the manifest:-->
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<!-- If you're sharing links, images or video via the Facebook for Android app, you also need to declare
the FacebookContentProvider in the manifest. -->
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider${facebook_app_id}"
android:exported="true" />
NOTE:
Your app is currently live and available to the public.
Follow below step to make your facebook app live and public:
1) Goto https://developers.facebook.com/
2) Select your app and goto App Review tab.
3) Check YES for Your app is currently live and available to the public. option.
See I am new How do I make my app live on FB
Your “applicationId” probably is "com.myname.blabla", and XXX your facebook app id?
I think you should switch to using 2 facebook APP_ID's, and not "applicationId". Put the facebook APP_ID's in your build types and reference them in your manifest. You then don't need to add the "applicationId" from your app.
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider${FACEBOOK_APP_ID}"
android:exported="true" />
Try with this:
If your APP_ID is 95xxx3xx60xx73xx, then it should be like:
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider95xxx3xx60xx73xx"
android:exported="true" />
For more information, you can follow this link.
I programmed hardcoded manifest file, like below:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="111111111111" />
In this case, facebook sdk couldn't detect meta-data definition.
But, the way to reference string value works well.
I aware the reason of using string resource file is for performance issue. however, there seems to be another reason.
What's that?
I agree with Mr. Murphy, I tried the same but at the end i had to put the Facebook App Id inside my Strings.xml, probably security reasons, your FB App Id must be "loaded from your project".
the example described in the documentation does the same:
To update your app, first add a reference to your App ID into the
AndroidManifest.xml file. Since you are no longer using your App ID to
instantiate a Facebook object, you will need to include the following
line to allow the SDK to identify your application on Facebook:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/app_id"/>
Next, add a string resource to your strings.xml file with your App ID.
<string name="app_id">12345678910</string>