Open ghost opened 4 months ago
I'm using Flutter 3.22.2 and facing the same problem right now. Somebody already encountered this issue in March, but it was unresolved at the time: https://github.com/MaikuB/flutter_local_notifications/issues/2255#issuecomment-1991301291. I will try to include the "classpath 'com.android.tools.build:gradle:7.3.1'" inside "dependencies" block alone. I will comment if that works.
I made it work. I got a local notification using the package. I included all the permissions they indicated in the Readme. I don't know if I'm implementing the notification feature correctly/efficiently, but here are my configuration files:
android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<application
android:label="borrar"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
android/app/build.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties() def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } }
def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { flutterVersionCode = "1" }
def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { flutterVersionName = "1.0" }
android { namespace = "com.example.borrar" compileSdk = 34 ndkVersion = flutter.ndkVersion
compileOptions {
coreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.borrar"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
multiDexEnabled = true
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
}
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 { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2' implementation 'androidx.window:window:1.0.0' implementation 'androidx.window:window-java:1.0.0' }
- android/build.gradle:
```gradle
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
ok thanks for your feedback, finally you didn't add this line in your project: classpath 'com.android.tools.build:gradle:7.3.1'.
It looks like that section is only present in android/build.gradle if your project is using Kotlin.
yes indeed it's a flutter project that uses kotlin , so I don't need to add this line ? com.android.tools.build:gradle:7.3.1 in my emulator it works without adding this line just so you know, I'm a backend developer and I'm new to mobile development. thx
The step for this is specifically on ensuring that AGP 7.3.1 is used at a minimum. If you cannot see that line there then it's likely that your app is on following new syntax. The Flutter docs cover this new syntax at https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply. They capture where you can specify the AGP version
Hello,
I am currently configuring a package in my Flutter 3 application for Android. I have reached the step where I need to add:
classpath 'com.android.tools.build:gradle:7.3.1'
to the android/build.gradle file. However, this file does not contain a buildscript section like:
Here is my android/build.gradle:
I also have a settings.gradle file in the root directory. Should I add com.android.tools.build:gradle:7.3.1 there instead?
If you have an example of the correct configuration, that would be very helpful.
Thanks.