Flutter Web error report sent to Sentry is not readable because is minified.
https://github.com/flutter/flutter/issues/37875
https://github.com/flutter/flutter/issues/16883#issue-316793104
I am use: https://pub.dev/packages/sentry
How I can make report not minify so I can read?
Give this a try:
When you build your app, use the --source-maps option to enable building the source maps:
flutter build web --source-maps
Then, upload the source maps to Sentry using the command line interface:
sentry-cli releases files "myapp-1.0.0+1" upload-sourcemaps /Users/me/myapp/build/web
Related
guys!
I am developing a desktop POS application for a shop. The application should have a feature to print some docs and barcodes. I have used pdf package to generate pdfs, but I am having a trouble with installing and using the priting package on Windows.
The main problem is with isntallation. In the docs, it says you should add the following lines in
CMakeLists.txt
file:
...
set(PDFIUM_VERSION "4929" CACHE STRING "" FORCE)
set(PDFIUM_ARCH "x64" CACHE STRING "" FORCE)
...
I am very confused in which CMakeLists.txt I shall put, because flutter's windows folder includes multiple files with the same name and extension. (windows\CMakeLists.txt, windows\runner\CMakeLists.txt, windows\flutter\CMakeLists.txt)
I have put the same piece of code into these different files, but none of them worked.
It always gives some errors like below:
errors
The thing I wanted to accomplish is to just print a generated PDF:
code
I'm having the same issue
What I do is
Flutter clean
Flutter pub get
Uninstall the previous application
Run the app again
And it worked
go to your terminal and type the following commands.
Flutter clean
Flutter pub get
now close the app
build the app again
hope this works for you. thanks.
please help me for the steps to obfuscate the code, step by step until it's finished?
and how do I see if my obfuscate code is successful or not.
Previously I tried running this command "flutter build ios --obfuscate --split-debug-info = / / " but an error appears like this: bash: syntax error near unexpected token `newline ', why the error?
The "obfuscate" function will split the debug-info for your Flutter app when building for the respective platform. for e.g., if your preparing to ship the version 2.0.1, then you'll get a folder named "2.0.1" which shall contain the .symbols files.
Now about how to get this done is by using this command flutter build ios --obfuscate --split-debug-info=debug-info
This will create a folder named debug-info in the root directory of your project and if you do have a new directory created in that after running the above command, then it means that the obfuscation was successful.
flutter build web will build my flutter app with obfuscation and minification.
I want my error stack to be readable though.
How should I modify the command?
Try:
flutter build web --profile --dart-define=Dart2jsOptimization=O0
See:
https://github.com/flutter/flutter/blob/720dff6a94bd054e82ec4bf84b5cb802bbc52ddd/packages/flutter_tools/lib/src/build_system/targets/web.dart#L238-L239
There's an issue on github for this feature, feel free to upvote ;)
https://github.com/flutter/flutter/issues/96283
This is a old post, but I found the answer.
If you build the app with this line:
flutter build web --profile --source-maps
Then when you print a stacktrace, you'll get something like this:
Exception: Hello
at Object.wrapException (js_helper.dart:1123:37)
at _MyHomePageState__incrementCounter_closure.call$0 (main.dart:64:7)
at _MyHomePageState.setState$1 (framework.dart:1114:28)
at _MyHomePageState._incrementCounter$0 (main.dart:57:5)
at tear_off.<anonymous> (js_helper.dart:2099:9)
at _InkResponseState.handleTap$0 (framework.dart:909:26)
at tear_off.<anonymous> (js_helper.dart:2099:9)
at TapGestureRecognizer.invokeCallback$1$3$debugReport (recognizer.dart:253:16)
at TapGestureRecognizer.invokeCallback$2 (recognizer.dart:239:6)
at TapGestureRecognizer.handleTapUp$2$down$up (tap.dart:627:11)
If you use --source-maps with a release build, you will still get the dart file and line number, but the class/method names in the stacktrace will be obfuscated.
And, if you copy the lib directory into the root of built web directory, it will display the source code when you click on the dart file/line number in the stacktrace. Also, you can set breakpoints in the dart code, just like you can do when you do flutter run web.
The only way I have found to do this is to use flutter run -d chrome. We would then need to locate where the files on disk are located.
Flutter's wiki mentions obfuscation is an opt-in in release mode.
And yet, the flutter build command has no relevant option - see:
flutter help -v build apk
Am I missing something here?
Did they make obfuscation the default?
Is obfuscation even relevant for flutter?
Any pointers on this would be very appreciated.
Obfuscation is needed - a flutter app knows its function names, which can be shown using Dart's StackTrace class. There's under-tested support for obfuscation. To enable it:
For Android:
Add to the file [ProjectRoot]/android/gradle.properties :
extra-gen-snapshot-options=--obfuscate
For iOS:
First, edit [FlutterRoot]/packages/flutter_tools/bin/xcode_backend.sh:
Locate the build aot call, and add a flag to it,
${extra_gen_snapshot_options_or_none}
defined as:
local extra_gen_snapshot_options_or_none=""
if [[ -n "$EXTRA_GEN_SNAPSHOT_OPTIONS" ]]; then
extra_gen_snapshot_options_or_none="--extra-gen-snapshot-options=$EXTRA_GEN_SNAPSHOT_OPTIONS"
fi
To apply your changes, in [FlutterRoot], run
git commit -am "Enable obfuscation on iOS"
flutter
(Running "flutter" after the commit rebuilds flutter tools.)
Next, in your project, add following to [ProjectRoot]/ios/Flutter/Release.xcconfig file:
EXTRA_GEN_SNAPSHOT_OPTIONS=--obfuscate
PS: Haven't tried the --save-obfuscation-map flag mentioned at https://github.com/dart-lang/sdk/issues/30524
Again, obfuscation isn't very well tested, as mentioned by #mraleph.
AppBundle (recommended):
Without splitting:
flutter build appbundle --obfuscate --split-debug-info=/<directory>
Splitting:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64 --obfuscate --split-debug-info=/<directory>
APK:
Without splitting:
flutter build apk --obfuscate --split-debug-info=/<directory>
Splitting:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi --obfuscate --split-debug-info=/<directory>
PS: About Splitting:
By default, fat apk contains arm v7, arm v8 and x64 which increases apk size, which you don't want to. So, when you split it, you have separate binaries which you can upload on the store and thus reducing the size of the apk that a user would need to download.
All the above answers are correct, but no answer tells you that we need to add a relative path or directory path while generating build.
Example using Relative Path:
flutter build apk --obfuscate --split-debug-info=./ProjectFolderName/debug
Example using Folder Path:
flutter build apk --obfuscate --split-debug-info=/Users/apple/Desktop/items/debug
The above command will generate a build inside the given project directory, it will create a new folder called ProjectFolderName or 'debug' on the respective command, and there you can find the release build.
https://flutter.dev/docs/deployment/obfuscateRefer this link for more info
Note: Flutter’s code obfuscation, Supported as of Flutter 1.16.2.
For Android the process is pretty clear from the doc at https://flutter.dev/docs/deployment/obfuscate. For Example:
export version=1.0.0
flutter build apk --release --shrink --obfuscate --split-debug-info=misc/mapping/${version}
Several files will be created such as misc/mapping/1.0.0/app.android-arm64.symbols (which you'll likely want to keep in VCS)
For iOS it's a bit less obvious since you often use the Xcode menu: Product > Archive
make an obfuscated build for iOS
flutter build ios --release --obfuscate --split-debug-info=misc/mapping/${version}
it creates file misc/mapping/1.0.0/app.ios-arm64.symbols
This will also modify ios/Flutter/Generated.xcconfig to include
DART_OBFUSCATION=true
SPLIT_DEBUG_INFO=misc/mapping/1.0.0
Use Xcode menu: Product > Archive which will uses Release.xcconfig which includes updated Generated.xcconfig
#include "Generated.xcconfig"
So your uploaded Archive will now be obfuscated (you don't need to make changes to Release.xcconfig)
See also - https://github.com/flutter/flutter/issues/64626#issuecomment-736081173
At the moment obfuscation is not directly exposed via the flutter CLI.
You can try to explicitly pass arguements to the gen_snapshot like this:
flutter build --extra-gen-snapshot-options=--obfuscate,--save-obfuscation-map=build/symbols.json --release
Note: that obfuscation support is not very well tested and might not work at the moment.
For iOS edit ios/Flutter/Release.xcconfig
This file should contain something like
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
If you check Generated.xcconfig there is a line DART_OBFUSCATION=false
So add opposite to the end of the Release.xcconfig file to override:
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
DART_OBFUSCATION=true
SPLIT_DEBUG_INFO=obj_maps
You can optionally add TREE_SHAKE_ICONS=true here to tree-shake icons as well
I'm trying to figure out what's the best process to pass from the code to the final deployable apk/ipa.
So far I have a testsuite using Karma + Jasmine, which transpiles the TypeScript to JS and runs some unit tests. I start that process via gulp.
After that all I know is to ionic build android --release what generates (an unsigned yet) apk.
But I'm not sure of how ofuscated/minificated the generated apk is.
So, keeping in mind the code has to be as private as possible, is the minification and the ofuscation of the ionic build enough or should I do all those prebuild tasks manually via gulp?
And in that case, whats are the right tasks I should run, do I have to transpile all the TypeScript files to JS manually? and in what order should I run the tasks?
E.g. transpile -> tests -> minify -> uglify -> build apk or minify -> uglify -> transpile -> tests -> build apk
I'm a bit lost with this, and the only thing I can figure out is that the tests should be ran first, because is case of test failure the process should be aborted.
Try ionic-app-scripts >= 0.0.48 to config build.
Production:
ionic build android --prod
To check the minified file, open the apk file with GNOME Archive Manager (or similiar) and extract /assets/www/build/js/app.bundle.js file.
Preparing an Ionic Cordova app for release in production
1. Building
In your terminal execute the following command according to your platform (android / ios):
ionic build android --prod --release
2. Releasing
In order to be able to install a production application on a device and furthermore in order to be able to publish it in app stores, your .apk or .ipa
file needs to be signed. How you do that depends on the platform.
Here is the procedure in detail for Android and for iOS.
Preparing an Ionic Progressive Web App (PWA) for release in production
1. Building
In your package.json file, you should make sure to have something like the following:
"scripts": {
// ...
"build:www": "rm -rf www && ionic-app-scripts build --prod",
// ...
},
Now in your terminal run:
npm run build:www
2. Releasing
Your app is built in the folder www ready for you to serve in production using any webserver like NginX, Apache or a custom Node + Express webserver.
Valid as of Ionic v3.3
Learn more about ionic-scripts, what they do and which other scripts you could possibly find useful.