Remove console logs from ionic app (release) - android

How do I get rid of console logs from an ionic 2 release application?
I am developing an ionic 2 app. When I build the release apk and run on a device, I can still attach to the process from chrome://inspect, and view console logs. I have tried removing the cordova-plugin-console, but that makes no difference.
Edit: I found a package that can remove console logs: https://www.npmjs.com/package/remove-console-logs
Just not sure how I can use it to automatically remove them when I build release. Please help.
Thanks.

You can use uglifyjs.config.js for drop all console logs when is a production build.
1 . Copy uglifyjs.config.js from node_modules into your project folder
2 . In the new config file set the flag drop_console to true if production
var isProduction = process.env.IONIC_ENV === 'prod';
...
compress: {
drop_console: isProduction
}
3 . Set your custom configuration in the package.json
"config": { "ionic_uglifyjs": "uglifyjs.config.js" },
And that's all !

If you can still connect with the debugger then it is not a release build - sounds like you may be unintentionally installing the debug build OR connecting to some other app.
EDIT; Above is not necessarily true - there are instances where you can debug the js/html/css content via chrome in a release build ; specifically if the webview debuggability flag is set in code / not set by the build system etc. - this flag is seperate from the application debug flags so if not properly set you will be able to debug a "release" build / not be able to debug a "debug" build - see remote debugging webviews.
END OF EDIT.
( note you have to sign a release build before it will install )
Is it possible the release install failed and you're still looking at a previous debug build ?
Assuming you have a release build and can't connect to see logs via chrome inspect then ;
console.log calls will still be in the release build unless you comment them out - and possibly visible in other ways eg. android tools sdk\tools\monitor - The only way to be sure they aren't visible is to comment them out. You could use something like ;
console.log = function(){} ;
at the end of your device ready function after any plugins have done anything they're likely to do - though there's still no 100% guarantee with this as a badly behaving 3rd party plugin or library might reassign it later and then your calls will still happen - to be absolutely sure you will need to comment them out.

Have you tried remove console logs ?
cordova plugin rm cordova-plugin-console
Then
cordova build --release android

Related

App Center force update for Android not working

i am trying to implement the force update feature using app center, i have followed their documentation found here and it doesnt seem to work at all
here's the code inside the App Class
AppCenter.start(
getApplication(), {APP SECRET HERE}, Crashes::class.java,
Distribute::class.java, Analytics::class.java
)
and i have tried uploading a build like this then downloading first, and after that i uploaded a newer version with higher version code / version name and set the checkbox for "Mandatory Update", i don't get any prompt at all to update when i start the app then.
Found the problem with the appcenter force update, AppCenter Distribute will not work on release mode if debuggable in gradle is set to true.
so make sure to leave it on false at the build type you will be testing on
debuggable false
adding this line before starting AppCenter showed me the logs that clued me to this.
AppCenter.setLogLevel(Log.VERBOSE)

cannot send crash report after setting up react native crashlytics for android

I feel like I have tried every possible combination of ways to report a crash on the firebase crashlytics console for the android side of my react-native application.
I have followed the rnfirebase setup instructions and triple checked that everything is where it should be: https://rnfirebase.io/crashlytics/android-setup
I have read in several forums that the app needs to be run in 'release' mode for the crash to be reported and then the app must be closed and opened once again for the report to be sent, I have done this multiple times:
firstly i've tried:
./gradlew installRelease
secondly I tried a method recommended in a github issue forum:
./gradlew assembleRelease
adb install ./app/build/outputs/apk/release/app-release.apk
both methods ran on my emulator and I was able to use the crashlytics().crash() method to cause a crash, alas nothing appears in the console.
I have also added this into a firebase.json file in the root of my project like the docs explain:
{
"react-native": {
"crashlytics_debug_enabled": true
}
}
any help is greatly appreciated as I really don't know where the issue lies.
PS. I have registered my app with the FB console and enabled crashlytics
in firebase.json
{
"react-native": {
"crashlytics_disable_auto_disabler": true,
"crashlytics_debug_enabled": true
}
}
make sure that crashanalytics sdk is installed/initialised
follow: https://rnfirebase.io/crashlytics/android-setup

DryIoc Container Exception only in RELEASE mode for XF w/ Prism Android App

I am getting the following exception, but only in the RELEASE build for a Xamarin.Forms Android app built with Prism w/ DryIoc container and the Popups Plugin (which the exception is referring to). The app runs fine in DEBUG. I am only using SDK assembly linking.
Has anyone run into this?
Any suggestions for determining root cause/fixing?
I get this exception when running in Release mode only and I have no idea why - can someone please help me with this? Works perfectly in Debug mode.
The exception gets thrown when attempting to do the first navigation (using INavigationService.NavigateAsync).
DryIoc.ContainerException: 'Unable to resolve
MyProject.ViewModels.LoginPageViewModel with passed arguments
[value(Prism.Plugin.Popups.PopupPageNavigationService)]
IsResolutionCall from Container without Scope with Rules with
{AutoConcreteTypeResolution} and without
{UseFastExpressionCompilerIfPlatformSupported} with
Made={FactoryMethod=ConstructorWithResolvableArguments} Where no
service registrations found and no dynamic registrations found in 0 of
Rules.DynamicServiceProviders and nothing found in 1 of
Rules.UnknownServiceResolvers'
I'm using:
Visual Studio Enterprise version 16.2.5 on Windows 10
Xamarin Forms version 4.2.0.778463
Prism.DryIoc.Forms version 7.2.0.1367
Prism.Plugin.Popups version 7.2.0.573
Rg.Plugins.Popup version 1.1.5.188
Here are my release csproj settings, which I modified to let me debug it on my physical device:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <!-- get rid of debug -->
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AndroidSupportedAbis>armeabi-v7a;</AndroidSupportedAbis>
<AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<BundleAssemblies>false</BundleAssemblies>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<AndroidEnableMultiDex>false</AndroidEnableMultiDex>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
</PropertyGroup>
Here's the registration in App.xaml.cs, and I have decorated the App class with Prism's [AutoRegisterForNavigation]. I Tried to explicitly register PopupNavigationService and Popups (the first 2 commented out lines) but it didn't make a difference.
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// Services / Plugins
//containerRegistry.RegisterInstance<IPopupNavigation>(PopupNavigation.Instance);
//containerRegistry.Register<Prism.Plugin.Popups.PopupPageNavigationService>();
containerRegistry.RegisterPopupNavigationService();
containerRegistry.RegisterInstance<IContactService>(CrossContactService.Current);
containerRegistry.Register<IDialogService, DialogService>();
containerRegistry.Register<IQuoteProviderService, QuoteProviderService>();
containerRegistry.Register<IMessageCheshirerService, MessageCheshirerService>();
containerRegistry.Register<IMessageTrackerService, MessageTrackerService>();
containerRegistry.Register<IEmailService, SendGridEmailService>();
containerRegistry.Register<IAnalyticsService, FakeAnalyticsService>();
containerRegistry.Register<IAuthenticationService, FakeAuthService>(); // note this overrides the real platform-specific implementations as desired
containerRegistry.Register<IApiManager, FakeApiManager>();
containerRegistry.Register<IInAppPurchaser, FakeInAppPurchaser>();
containerRegistry.Register(typeof(IApiService<>), typeof(ApiService<>));
// Non-Auto-Registered Views
containerRegistry.RegisterForNavigation<NavigationPage>();
}
This error message was a red herring for a completely different, nested dependency that was not properly registered for the release mode build.... please disregard.

Requiring unknown module "react-native-safari-view" in Release mode

I have a React Native project and it runs successfully on both simulators and devices for iOS.
However, for Android, it runs successfully on simulators without any problems, but when run on devices as a Release build, it gives me this error:
Requiring unknown module "react-native-safari-view".
I tried npm cache clean and npm install several times, but it does not work.
The module exists in node_modules folder and it is also under dependencies in package.json.
What could be the cause of this? Why does it happen only in Release builds?
Update: If this is difficult to fix, is it possible to generate a signed apk with the js bundle included in dev mode?
It is because react-native-safari-view module is not designed for Android.
Check this out: (inside index.android.js file in GitHub)
var SafariViewManager = {
test: function() {
warning('Not yet implemented for Android.');
},
isAvailable: function() {
...
}
};
Maybe you are initiating a SafariViewManager object and calling other functions like show() in index.ios.js without checking it isAvailable()?

Crashlytics for Android: Disable automatic upload of mapping file via Gradle build

I'd like to use crashlytics in our app, but I'm not allowed to upload it's proguard mapping file anywhere to the outside world (company policy). Is it possible to use Crashlytics but with obfuscated stacktraces?
In io.fabric plugin's docs I've found this option:
ext.enableCrashlytics = false
But it disables whole reporting, so that's not what I want.
I have added this at the end of app gradle file:
tasks.whenTaskAdded {task ->
if(task.name.toLowerCase().contains("crashlytics")) {
task.enabled = false
}
}
Build log:
> Task :app:crashlyticsStoreDeobsDebug SKIPPED
> Task :app:crashlyticsUploadDeobsDebug SKIPPED
Please note that this disables all crashlytics related tasks. Uploading proguard mapping file by default is some kind of misunderstanding. It is like uploading private key and its password. This file should only be stored in your vault. So I guess it is better to completely disable all their task by default :)
I am just wondering why this is not a big issue for developers.
They have everything planned ! ;-) According to this link : "Crashlytics automatically de-obfuscates stack traces for your reports", so you shouldn't have to worry about it.
Simply obfuscate your app with ProGuard, don't forget to update ProGuard rules to avoid unexpected crashes with release app, and it should be ok !
(help page is about Eclipse, but I used Crashlytics with Android Studio just some days ago, and it works fine too)
EDIT 1 : and according to the very end of this second link, Crashlytics automatically upload mapping file during build. It seems you aren't able to disable this.
EDIT 2 : maybe if you use Ant, you would be able to customize (at least a bit) build rules, thanks to crashlytics_build.xml and crashlytics_build_base.xml files. But I'm not used to Ant, and even there, when I read file, it seems the "mapping files auto upload" can't be disabled. :-/
try disable task 'crashlyticsUploadDeobs':
afterEvaluate {
for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) {
task.enabled = false
}}
Add to app build Gradle file
firebaseCrashlytics {
mappingFileUploadEnabled false
}
https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android
if you does not have internet connect at that time what will happened mapping will upload to crashlytics or not.

Categories

Resources