I'm trying to add flutter_blue package to normal working flutter code on Android Studio(Windows) and getting an Error:
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_blue-0.5.0\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':flutter_blue'.
> Failed to apply plugin 'com.google.protobuf'.
> Could not create an instance of type com.google.protobuf.gradle.ProtobufSourceDirectorySet.
> 'void org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(java.lang.String, java.lang.String, org.gradle.api.internal.file.FileResolver, org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)'
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 389
* What went wrong:
A problem occurred configuring project ':flutter_blue'.
> Failed to notify project evaluation listener.
> Could not create an instance of type com.google.protobuf.gradle.ProtobufSourceDirectorySet.
> 'void org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(java.lang.String, java.lang.String, org.gradle.api.internal.file.FileResolver, org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)'
> Cannot invoke method substring() on null object
> compileSdkVersion is not specified. Please add it to build.gradle
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
Here is app\build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.project"
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
Here is project pubspec.yml dependencies:
environment:
sdk: ">=2.15.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_blue: ^0.5.0
flutter_secure_storage: ^5.0.2
flutter_local_notifications: ^9.3.2
firebase_core: ^1.0.3
firebase_messaging: ^11.2.6
dio: ^4.0.0
cached_network_image: ^3.2.0
intl: ^0.17.0
syncfusion_flutter_charts: ^19.4.53
path_provider: ^2.0.9
path: ^1.8.0
cupertino_icons: ^1.0.2
flutter_platform_widgets: ^1.20.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.9.0
flutter_lints: ^1.0.0