Use dummy API key for Travis CI - android

My Android app uses Google Payments and I store the API Keys in a values xml that is not added to VCS (used .gitignore file). I reference the value as R.string.api_licence from my code.
When I setup travis for CI, it was complaining that R.string.api_licence was not found. As a work around, I checked in a dummy text file with empty value for the key and rename the extension to xml from travis build script.
While this is working for now,
1 - This doesn't seem like a perfect solution
2 - Android Studio complains that the dummy txt file name should be of xml extension, and I have to delete it locally to work, which leads me to accidentally commit and break the builds sometimes
Travis script file: https://github.com/midhunhk/message-counter/blob/master/.travis.yml
Notes: I am a self taught Android developer. I don't require the real API keys to be used for CI process. I did some considerable research on this topic and couldn't get a specific answer to my problem.

I think the following approach can be used for solving this issue. I never got to test this as I changed my API implementation and may not need to store the API key in the source code.
https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings

Related

Unity Generation of the Firebase Android resource file google-services.xml from Assets/GoogleService-Info.plist failed

I would like to setup Firebase in Unity 2020.1.14.
I downloaded the GoogleService-Info.plist into my assets folder and set up a project in the Firebase console.
But as soon as I import the FirebaseAnalytics 7.0 package I'm getting this error:
Generation of the Firebase Android resource file google-services.xml from Assets/GoogleService-Info.plist failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.
"python" "/Users/joerg/Projekte/UnityTest/FirebaseTest2012042/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/GoogleService-Info.plist" -l --plist
Could not find key in plist file: [DATABASE_URL]
How do I set the [DATABASE_URL] in GoogleService-Info.plist?
Thanks
Joerg
This was really frustrating. There is no mention on the original setup tutorial about this issue. I'm assuming more people are going to run in to this problem. So here is the solution:
Go to Firebase Console
Choose your project
Go to "Realtime Database"
Create Realtime Database
After database is created.
Go to "Project Settings"
Download google-services.json and GoogleService-Info.plist
Replace these files in you Unity project. (these files should be inside of the Assets folder, or if you've created a Data folder, then you can find them there.)
In the newly generated files there is a "firebase_url":. Which was missing before. This should now fix this particular error message.
Ok, I found the solution: I just had to setup a database in the Firebase Console and then the url is written to the plist file.
This wasn't mentioned in the Google tutorial.
Simple solution, just add those lines:
<key>DATABASE_URL</key>
<string>https://unexisting.fake.database.firebaseio.com</string>
p.s. I would not recommend enabling database service since it's paid. If for some reason, some plugin will attempt to use it in some way, you will be charged. The only reason I am not using those awesome paid services from Google is that they are only POST PAID without ability to set limit (except you wrote some complicated script yourself which will run in real time and will turn off services once you reach certain limit). There are lot of developers stories who woke up with 5-10k bills due to some error in script.

Differentiate crash reporting between debug and production builds

I'm setting up Firebase Crashlytics for my Android app, and I would like the crash reports for the debug version to be separate from all other versions.
There are several copies of the auto-generated values.xml file (that is generated when the google-services plugin processes toe google-services.json file) located in the different retrospective buildType folders. One of the strings contained in the files is:
<string name="google_crash_reporting_api_key" translatable="false">{API-KEY}</string>
The API key is the same for each buildType, so I'm thinking if I can just create a new API key for the debug version, it'll solve the problem but how to do this? Or is there another way (that doesn't involve changing the applicationId as I can't do this)?
I've searched the android docs, looked up other articles and looked through other SO answers but no luck.
Any help welcomed, thank you.
You cannot differentiate the crash as per the build type (debug version).
You have to create a new project in the firebase with same app details (package name).
Get the API key for the project and then replace that key in your manifest file and DONE.
You just have to replace the key when you change your build Type.

After Compile In Android Studio My APK Contents Are Dated 1980?

Hello i have a rather small issue but in a small way its a massive issue as googleplay keep rejecting my app because of it.
Here is my issue:
Screenshot the my apk contents
So all the files in my apk after compiling with a newly created keystore (or without and unsigned) are date at 1980 as in the picture above. my androidmanifest.xml is also the same?
This is really annoying i have tried timestamping methods here on stackoverflow without any success.
I have been throught the whole project in android studio for any related configuration in settings and code. i have re-installed android studio jkd,ndk,sdk and still its the same.
Anit help on solving this issue would be greatly appreciated.
Thank You
This is intentional, it reduces changes between apks.
If you want to avoid this you can add the following setting to your gradle.properties file:
android.keepTimestampsInApk = true
According to my tests it will change only some of the timestamps (e.g. classes.dex) in the apk and keep some of the timestamps (e.g. AndroidManifest.xml).
source: https://issuetracker.google.com/issues/37116029

Firebase crash: how programmatically upload mapping file?

Firebase crash is a cool tool but as fair as I know there is not any way to programmatically upload Proguard mapping file via API after a build.
Recently, "automate file uploads" options appairs but no info are actually aviable in the learn more link.
Does anyone know something more?
On 15th December the Crash Reporting plugin was released by google: it will generate a gradle task that performs the upload of ProGuard mappings file to Firebase Crash.
Here the steps to use it:
https://firebase.google.com/docs/crash/android#uploading_proguard_mapping_files_with_gradle
Unfortunately, this looks to be an IOS only feature right now: https://firebase.google.com/docs/crash/ios#upload_symbol_files.
Upload symbol files
In order to view human friendly crash reports, you need to upload symbol files after each build. This can be done automatically by adding a run script to Xcode.
Download a service account key to authenticate your uploads. From the Firebase console, select your project and then click Generate New Private Key.
In Xcode, click on your application target, select Build Phases, and click + to add a phase.
Select Run Script and add the following content, setting appropriate values for your service account path and GOOGLE_APP_ID:
Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:my:app:id
Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
"${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"
Note: If your service account key changes, reset your OAuth credentials by running this command:
rm $HOME/Library/Preferences/com.google.SymbolUpload*

Update Google Play services from 8.x.x to 9.x.x

I have a working Android app using:
Google Maps (play-services-maps)
Google Location, Activity Recognition, and Places (play-services-location)
Google Analytics (play-services-analytics)
Google Mobile Ads (play-services-ads)
I'm currently using version 8.3.0, everything works fine. I'd like to upgrade to the last version, 9.2.0. When I change the number in the gradle files, Android Studio is unable to find the APIs packages & classes (saying "package XXX does not exist" and "Cannot find symbol class YYY").
I currently have no google-services.json file, do I need it now? I tried without success, probably because I have several modules / submodules, and I don't know where the json file is needed or not.
The problem is that I need a package name to create the JSON file, and I have some library modules, without package name, using Google APIs.
If needed, here is the project structure:
Maybe you did something wrong while upgrading your project. Make sure you follow the correct steps in upgrading. I suggest you to retry the process of upgrading, but make sure you do the correct way. Like in configuring your build and setting up Google play service.
For your question about google-services.json, Google-services.json contains developer credentials and configuration settings, which is needed to verify while connecting with GoogleApiClient. Though your service is working fine without it. But it will only work with your test device, as it is detecting your developer account. And after you releae your app in public, it will not work without the json file. So you need it and don't delete.
sources: What does google-services.json really do?
So, I finally got it: I was using the AutocompletePrediction.getDescription() method, which has simply been removed (and replaced by AutocompletePrediction.getDescription .getFullText()). That call made gradle stops building -_- .
Thanks Google for removing stuff without deprecating it for a while (though the docs says that the method is deprecated: https://developers.google.com/places/android-api/releases)...
I can also confirm that in my case, the google-service.json file is NOT required.

Categories

Resources