How to work Flurry with debug mode on Android.? - android

I am using Flurry analytics for tracking apps behaviours. A lot error is thrown while App is developed, I can find and fix that error on Android console however these errors are uploaded to Flurry Console and They are confusing me.
I used below codes to intercept these but This time Flurry doesn't work at all.
if( !BuildConfig.DEBUG ){
// configure Flurry
FlurryAgent.setLogEnabled( false );
FlurryAgent.init( this, MY_FLURRY_APIKEY );
formValidationHelper = new FormValidationHelper();
}

What your code is doing is preventing Flurry initialization in debug mode, which, I assume, is not what you want to do. If you want the SDK to work in debug mode, you should still call FlurryAgent.init(Context, String).
There are several ways to do this. The definite way is to create another Flurry API key for your debug development and use your main API key for release.
If you want to remove Flurry crash-reporting altogether, you can do that using FlurryAgent.setCaptureUncaughtExceptions(boolean). The default for this setting is true so Flurry will send crash information to the dashboard. You could, of course, leave it as default when releasing your app, but can turn it off during development.
Here's a snippet showing what I mean about using different API keys and disabling crash-report in debug mode:
if (BuildConfig.DEBUG) {
FlurryAgent.setLogEnabled(true);
FlurryAgent.setCaptureUncaughtExceptions(false);
FlurryAgent.init(this, FLURRY_DEBUG_KEY);
// Other debug setup
} else {
FlurryAgent.setLogEnabled(false);
FlurryAgent.init(this, FLURRY_RELEASE_KEY);
// Other release setup
}

Related

Analytical Console juts Logs "InternalRequestSender outbound"

Hi when ever i tried to use Android Debug Apk everything in my logs gets logged and everything works fine.
But if i try to use my release apk i only get only the below message in the logs i have verified my debugger level and its Debug and i have changed it to verify as well but still no luck.
Package wl.analytics
Level Analytics
Message InternalRequestSender
outbound
We are using cordova-plugin-mfp: 8.0.2018090313
Server MFP: 8.0.0.00-20171220-1341
You mention the debugger level is set to Debug. Since it is in debug mode, only with a debug mode apk you will see the logs.
You should try with a different loglevel than debug, for instance INFO level. Make sure you use setLevel API explicitly and override the default with the one you want.
Alernatively you can use customData too if it is not just logging purpose.

How to cancel console.log messages in ionic release/production apk

I am using ionic, and in the publishing phase I am following the instructions here: http://ionicframework.com/docs/guide/publishing.html
The release apk is generated, but it's still outputting the console.log messages when I view the app's logcat.
I do not have the "cordova-plugin-console plugin" installed (never had).
This maybe not a right answer about your question, but I'll provide an alternative solution for debugging with console. Because I don't know why your app could print out messages from the console.log without that plugin.
If you had never installed the cordova-plugin-console plugin before, the best ways is write down your own Logging factory/class/function with a switcher flag. This should be the wrapper of the console.log.
During the debugging, call your logging function.
In your logging function, check if switcher flag is enabled, then invoke the console.log, else do nothing.
Here is an example:
yourApp.factory('Debug', [function(){
var IS_DEBUGGING = true; //change this to false whenever you want to release your app.
return function(msg){
if (IS_DEBUGGING) {
console.log(msg);
}
}
}]);
I suggest do this as a factory, you could customize and extend this for the logging level of your app.

Fail Android Release Build if LOCAL_SERVER is True?

Every so often, after some local testing, I build and sign a version of my Android app for the Play Store that has the LOCAL_SERVER flag still set to true. Of course this causes the app to fail for people because, in general, my users can't reach a my 192.168.1.x server.
Is there any way to get the release process to somehow auto-detect that I've left that constant in the "testing" state and fail before it gets accepted by Google Play?
I thought maybe I could conditionally call a dummy class and
have ProGuard (which only runs on a "release" build) force-strip that class which would then generate an
error because it found a call to a class that wasn't present.
But ProGuard has no option to force-strip a class.
I thought maybe I could force "android:debuggable=true" which would
then cause the upload to Play Store to fail. But I can't find any way to
set that AndroidManifest flag based on a Java constant.
Any other ideas?
I'm using Eclipse for development.
A release checklist.
Test the signed version before releasing it.
A JUnit test that checks the field's value (you still need to remember to run it though).
Even better, stop LOCAL_SERVER being set.
class MyClass
{
final private boolean USE_LOCAL_SERVER = true;
void myMethod()
{
LOCAL_SERVER = (MyClass.class.getName().equals("mypackagename.MyClass")) ? USE_LOCAL_SERVER : false;
}
}
Since proguard will obfuscate the name of MyClass, LOCAL_SERVER will always be false when proguard has been run.

Disable GoogleAnalytics from Android App when testing or developing

I'm using EasyTracker in my Android App and I need a way to disable Analytics tracking when the app is in "development" or "testing" mode (I have a flag in a constants file to discriminate).
What's the best way to do so?
Thanks!
I believe the correct way to do this with Version 4 of Analytics is with the Opt Out method
GoogleAnalytics.getInstance(this).setAppOptOut(true);
You could set that method to be set if you build in debug mode. ie.
GoogleAnalytics.getInstance(this).setAppOptOut(BuildConfig.DEBUG);
I am using something similiar to allow users to opt-out of analytics.
I found this information at he following link: https://developers.google.com/analytics/devguides/collection/android/v4/advanced
Edit: Just saw the date of the original question, but thought I would add this answer anyway as it was something I was looking for.
UPDATE: With release of Google Analytics v3 for Android,
The SDK provides a dryRun flag that when set, prevents any data from
being sent to Google Analytics. The dryRun flag should be set whenever
you are testing or debugging an implementation and do not want test
data to appear in your Google Analytics reports.
To set the dry run flag:
// When dry run is set, hits will not be dispatched, but will still be
logged as though they were dispatched.
GoogeAnalytics.getInstance(this).setDryRun(true);
+++ My old answer +++
Just comment the following line in your analytics.xml file while you are in development mode.
<string name="ga_trackingId">UA-****</string>
Google Analytics wouldn't be able to find any tracking id, so EasyTracker won't be able to do its job.
When you are building the app for release, uncomment the line and you're good to go.
If you are building a standalone app(not a library), this will be the easiest way to do it, let the build system figure out if it is a debug build or not.
if(BuildConfig.DEBUG){
GoogleAnalytics.getInstance(this).setDryRun(true);
}
I see on the web that this method does not work well for library projects as there is bug in the build tools which does not set the BuildConfig.DEBUG flag correctly for libraries. Not sure if this issue is fixed now.
You can use a class with a static boolean value let's say DEBUG like this :
public final class BuildMode {
public final static boolean DEBUG = true;
}
In code, just use :
if (BuildMode.DEBUG) ...
This is a solution working on all android SDK versions!
Newest version from firebase has this method that can be put inside App class:
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(!BuildConfig.DEBUG);
What I'm doing is disabling periodic dispatching, by setting a negative period, in analytics.xml:
<integer name="ga_dispatchPeriod">-60</integer>
or you can do it programmatically, using your flag:
if (testingMode) {
GAServiceManager.getInstance().setDispatchPeriod(-1);
} else {
GAServiceManager.getInstance().setDispatchPeriod(60);
}
That way hits are not sent unless you do it manually.
That should work if you are using only periodic dispatching (never calling .dispatch() manually). Hits not sent before 4 a.m. of the following day are somehow discarded, I guess, as they are not appearing in the reports anyway.
See in Google Analytics Developer Guide:
Note: Data must be dispatched and received by 4 a.m. of the following day,
in the local timezone of each profile. Any data received later
than that will not appear in reports.
More info: https://developers.google.com/analytics/devguides/collection/android/v2/dispatch
My technique is to change the android:versionName in Android Manifest until release time.
For example, 1.0.0.ALPHA until time to build a release APK, at which point you could change to 1.0.0. This way you can still see all of your crash reports later, but they will grouped in analytics.
This SO ticket talks about using the BuildConfig.DEBUG flag to conditionally configure analytics and Atul Goyal's answer references the dryRun flag in v3. Those two things could be a nice setup if you don't care about seeing crash reports during debug in the future, and assuming that the BuildConfig.DEBUG flag works correctly.
I have a different approach to this issue. Sometimes you still want to test that analytics is working correctly, but want to just filter test data out in production reports. My solution to that is to create a custom session-scoped dimension (i.e. AppBuild), in GA for the property which tracks if you are running a debug or production build of the app. In your code after you create the Tracker, put:
// replace 1 with the correct dimension number if you have other dimensions defined
tracker.set("&cd1", BuildConfig.DEBUG ? "debug" : "production");
Then create or modify your GA view to add a filter on AppBuild, excluding debug. This should filter out all debug data from your GA view. You can also add a new view to show debug data.

Android: Make the app logs my logging statements "only"

I am planning on signing an apk and releasing it (through Export Eclipse tool). Then upload it to the market. I know that debuggable is set to false by default when signing it so that means that no logs will be captured. At the same time, if I set debuggable to true and release the apk then I will get all the logs.
What I am really interested in is the last debug statement that are added by me only. Currently, I am using the Log.i statement to add info logs. Is there a way to have my app logging only the Info logs (i.e. my logs only). Mybe if I disable the log and have system.out.print it would work?
The reason I am doing this is becuase I want to send the last 100 lines of log when a crash happens and I am only interested in my log statments.
Please help me out
Thanks
I believe what you need to do is take advantage of ACRA's built in filtering functionality:
In the Advanced Usage wiki you can see that you can set your logcat arguments in your config.
In your logging, tag your custom log messages with a specific tag and debug level, then in the logcat arguments, then set a parameter:
logcatArguments = { "-t", "100", "-v", "long", "ActivityManager:I", "MyApp:D", "*:S" }
add one in the form of
"YourCustomTag:<YOUR_DEBUG_LEVEL>"
and take out the ones you don't want to be logged (probably MyApp:D in this case.)
You will have to put a wrapper on top of Log where you can put functionality to control the log levels.
This type of functionality is already implemented by the ACRA Android library. The library detects crashes, and send the crash information to either a Google Docs spreadsheet, or your own destination. You can add additional information like the past 100 lines of your log using the method shown here.

Categories

Resources