Skip to main content

Install Shake

Install

Add Shake as a dependency:

flutter pub add shake_flutter

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

pubspec.yaml
dependencies:
shake_flutter: ^

Now in your Dart code, you can use:

main.dart
import 'package:shake_flutter/shake_flutter.dart';

Set compileSdkVersion version in the build.gradle file

Since Shake requires compileSdkVersion 29 or greater, verify that compileSdkVersion is correctly set in the /android/app/build.gradle file.

build.gradle
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.shakebugs.flutter.example"
minSdkVersion 24
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}

Initialize Shake

Call Shake.start() method in your main.dart file. Replace your-api-client-id and your-api-client-secret with the actual values you have in your workspace settings.

main.dart
import 'package:shake_flutter/shake_flutter.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
Shake.setShowFloatingReportButton(true);
Shake.setInvokeShakeOnShakeDeviceEvent(true);
Shake.setInvokeShakeOnScreenshot(true);
Shake.start('your-api-client-id', 'your-api-client-secret');
runApp(Home());
}

Now build your project and see everything work! To build and run your app, select Run โ€บ Run in the menu bar. This first run will automatically add your app to your Shake Dashboard based on your app bundle ID.

note

Shake supports post Flutter 1.12 projects. If your project is created with the older version of Flutter, you should migrate your project to the new Android APIs via official guide.