I am trying to update my Flutter application to compile using Android 14 (API 34). When I try to sync my project through “Sync Project with Gradle File” in Android Studio (Android Studio Koala | 2024.1.1), I get an error:
Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
android {
namespace 'com.example.namespace'
}
If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant;
But I already set namespace on my app module build.gradle
I already tried Invalidating Cache and restart with android studio and also tried to delete cache of gradle without success.
My Flutter doctor:
[✓] Flutter (Channel stable, 3.7.12, on macOS 14.5 23F79 darwin-arm64, locale en-IT)
• Flutter version 3.7.12 on channel stable at /Users/username/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4d9e56e694 (1 year, 4 months ago), 2023-04-17 21:47:46 -0400
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/username/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/username/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
[✓] VS Code (version 1.91.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.92.0
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.89
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
This is my android/build.gradle:
buildscript {
ext.kotlin_version = '1.9.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my android/app/build.gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
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 {
namespace 'com.myapp.app'
compileSdk 34
ndkVersion "25.1.8937393"
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.myapp.app"
minSdk 22
targetSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
resourceConfigurations += ['en', 'it']
}
flavorDimensions "flavor"
productFlavors {
dev {
applicationIdSuffix ".dev"
dimension "flavor"
getIsDefault().set(true)
manifestPlaceholders = [appLabel:"Joivy DEV"]
}
staging {
applicationIdSuffix ""
dimension "flavor"
manifestPlaceholders = [appLabel:"Joivy Staging"]
}
prod {
dimension "flavor"
manifestPlaceholders = [appLabel:"Joivy"]
}
}
signingConfigs {
release {
keyAlias="MyApp"
keyPassword="br7Tuphetr$f"
// storeFile file(System.getenv("HOME") + "/Desktop/DV_AppMobile/myapp_prod.keystore")
storeFile file("myapp_prod.keystore")
storePassword="br7Tuphetr$f"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.dipien:bye-bye-jetifier:1.2.1'
}
}
packagingOptions {
resources {
excludes += ['META-INF/com.android.tools/proguard/coroutines.pro']
}
}
lint {
checkReleaseBuilds false
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//implementation "androidx.annotation:annotation-experimental:1.1.0"
implementation platform('com.google.firebase:firebase-bom:28.1.0')
}
and this is the android/gradle/wrapper/gradle-wrapper.properties:
#Thu Jul 13 11:44:22 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-8.0-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Alberto Callegari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.