Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CrashlyticsNdk #64

Merged
merged 3 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,58 @@ And apply the fabric plugin `apply plugin: 'io.fabric'`

Nothing more.

### Symbolicating Native Android Crashes
Unfortunately, even pure Dart projects can't always protect you from native
crashes. Without the following setup, a native crash like SIGSEGV will
appear as a blank stacktrace in Crashlytics. Here's how to get some symbols:

Add the following to build.gradle, after `apply plugin: 'io.fabric'`:

```
crashlytics {
enableNdk true
androidNdkOut "../../debugSymbols"
androidNdkLibsOut "../../build/app/intermediates/transforms/stripDebugSymbol/release/0/lib"
}
```

Ensure that the ndk-bundle is installed or the stripDebugSymbol directory won't
get created.

Now setup a release script to populate the debugSymbols directory, guided by
the instructions from https://github.com/flutter/flutter/wiki/Crashes

```
# Build our app like usual
flutter -v build apk --release

### BEGIN MODIFICATIONS

# Copy mergeJniLibs to debugSymbols
cp -R ./build/app/intermediates/transforms/mergeJniLibs/release/0/lib debugSymbols

# The libflutter.so here is the same as in the artifacts.zip found with symbols.zip
cd debugSymbols/armeabi-v7a

# Download the corresponding libflutter.so with debug symbols
ENGINE_VERSION=`cat $HOME/flutter/bin/internal/engine.version`
gsutil cp gs://flutter_infra/flutter/${ENGINE_VERSION}/android-arm-release/symbols.zip .

# Replace libflutter.so
unzip -o symbols.zip
rm -rf symbols.zip

# Upload symbols to Crashlytics
cd ../../android
./gradlew crashlyticsUploadSymbolsRelease

### END MODIFICATIONS

# Release our app like usual
cd ../..
fastlane submit_playalpha
```

### iOS
On iOS side your need to set your Fabric ID under your Info.plist like:
(Only do this if using Fabric, not Firebase as you will not have an Api Key)
Expand Down
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ dependencies {
api('com.crashlytics.sdk.android:crashlytics:2.9.8@aar') {
transitive = true
}
api('com.crashlytics.sdk.android:crashlytics-ndk:2.0.5@aar') {
transitive = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;
import com.crashlytics.android.ndk.CrashlyticsNdk;
import io.fabric.sdk.android.Fabric;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
Expand All @@ -29,7 +30,7 @@ public static void registerWith(PluginRegistry.Registrar registrar) {
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
if (methodCall.method.equals("initialize")) {
Fabric.with(context, new Crashlytics());
Fabric.with(context, new Crashlytics(), new CrashlyticsNdk());
result.success(null);
} else {
if (Fabric.isInitialized()) {
Expand Down