I'm working on this app project where I need to schedule notifications based on a list of predefined texts. Everything works fine on my dev environment, but when I build the APK release, they won't work. Debugging further I found out the notifications are a NativeModule and it becomes undefined on the release.
This returns the module attributes on react-native run-android but undefined in the release:
console.log(React.NativeModules.NotificationModule);
This is the actual error that led me to it:
Notification
.create({ attrs })
.then((n) => console.log('Notification', n)
.catch((err) => console.log(err);
Prints:
{ [TypeError: undefined is not an object (evaluating 'd.rGetApplicationName')] line: 670 column: 2663, sourceURL: 'index.android.bundle' }
I'm using react-native-system-notification with what I understand is an unrelated modification that removes the GCM requirement.
There's this issue but the project seems inactive since August and the issue is from April.
So, where else should I look for to solve this?
I dug into their source--it looks good. Almost feels like a configuration error on your end. Go through their installation steps really carefully, and in the output of ./gradlew assembleRelease, make sure you see it compiled/linked in the output. Also, make sure your React Native version is up-to-date.
I've disabled proguard from the release and the notifications started to work! No idea how to prevent proguard from messing with the package, but it was only saving 1Mb so I'm happy with this solution.
def enableProguardInReleaseBuilds = false
in android/app/build.gradle
Related
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
When building a project I get the following error:
Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
It happens only when using the pro version through the #progress registry. Doesn't happen with the local .tgz pro version.
I noticed the error has to do with the include.gradle file it generates. I read the following article: https://docs.nativescript.org/plugins/plugins#includegradle-specification
It says that when the plugin doesn't have the include.gradle, at build time gradle creates a default one with default elements. When I saw the include.gradle it generated for the plugin it seems to have generated a default one like so:
android {
productFlavors {
"nativescript-telerik-ui" {
dimension "nativescript-telerik-ui"
}
}
}
The include.gradle generated for the local .tgz version of the plugin is like this:
android {
productFlavors {
"F6" {
dimension "nativescripttelerikuipro"
}
}
}
I replaced the default include.gradle with the latter and it got past the error. You can recreate the problem by following these steps:
create a new hello world app
use the command npm login --registry=https://registry.npm.telerik.com/ --scope=#progress to log in if you're a paying customer.
use the command npm install --save #progress/nativescript-telerik-ui-pro to install the plugin
use tns run android
Is there anything I can do to solve this problem? Really need help on this.
My name is Vladimir and I am part of the nativescript-telerik-ui-pro team. Thank you for logging this issue in our feedback portal. We are going to review it as soon as possible and update you regarding its status, but from what I currently see there is some incorrect "parameters" passed to the 'pro' version of the plugin that are going to be resolved very fast.
We apologize for any inconvenience that this is causing.
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
I'd like strings.xml to be checked for spelling while building with gradle. Since we use continuous integration we need it to be configured for building from command-line not just in Android Studio. Any way to do it?
PS. I've tried:
lintOptions {
abortOnError false
// check *only* the given issue id's
check 'Typos'
}
strings.xml:
<resources>
<string name="app_name">Project</string>
<!-- Common Words -->
<string name="test_spelling">sdfsdfdfds</string>
and
./gradlew assembleDebug lint
but got nothing:
:app:lint
Ran lint on variant release: 0 issues found
Ran lint on variant debug: 0 issues found
Wrote HTML report to file:/Users/asmirnov/Documents/dev/src/Project/app/build/outputs/lint-results.html
Wrote XML report to /Users/asmirnov/Documents/dev/src/Project/app/build/outputs/lint-results.xml
Also i've checked lint --show :
...
Typos
-----
Summary: Spelling error
Priority: 7 / 10
Severity: Warning
Category: Correctness:Messages
This check looks through the string definitions, and if it finds any words
that look like likely misspellings, they are flagged.
...
PPS. If i add another rule to check (check 'Typos', 'TypographyEllipsis') i'm getting warnings (for TypographyEllipsis) as expected, so in general linting works. For some reason "Typos" rule is not working only
I am currently working on something similar, so have not completed my work. Not sure if you have an answer as yet, as it was asked a while ago. Here is what I have.
The code you have here:
lintOptions {
abortOnError false
// check *only* the given issue id's
check 'Typos'
}
should be fine. You can also add it within a flavor, to be more restrictive, if you are using them.
To get the report from the command line, you need to execute:
./gradlew lintAssembleDebug
or whatever your flavor is, e.g. ./gradlew lintAssembleMyFlavorDebug
I am trying to make use of the lintOptions.check() method, to programmatically add the checks I want, but no luck yet. Another alternative is as described here by Jason Atwood. I am looking at this, adding the blank file:
ext.lintCheckList = [
// Blank default list
] as String[]
to the repo, and replacing that in the CI job, as needed.
Hope that helps.
Update:
The command is incorrect. It should be
./gradlew lintDebug
or
./gradlew lintMyFlavorDebug
etc
If you do want spell check feature that is enabled by default in Android Studio IDE then follow the below given steps,
Go to Android Studio -> Preferences on your Mac OS X (Should be Window -> Preferences on Windows OS)
Now look for Inspections (if you cant trace it just use the Search)
Now look for the Spellings check box and check it (this also checks the Typo)
Apply and Close
Thats it!! You would now see any Typo or spelling correction highlights in Android Studio.
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.