1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Android getting error: Namespace not specified

Discussão em 'Mobile' iniciado por Stack, Novembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    I decided to use latest version of Gradle and after updating AndroidManifest.xml and build.gradle I get this error and I couldn't solve it

    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; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.


    application build.gradle

    dependencies {
    classpath 'com.android.tools.build:gradle:8.0.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }


    gradle.wrapper.properties:

    distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip


    AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application
    android:label="xxxxx"
    android:name="${applicationName}"
    android:icon="@mipmap/ic_launcher">
    <activity
    android:name=".MainActivity"
    android:exported="true"
    android:launchMode="singleTop"
    android:theme="@style/LaunchTheme"
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
    android:hardwareAccelerated="true"
    android:windowSoftInputMode="adjustResize">

    <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>

    <meta-data
    android:name="flutterEmbedding"
    android:value="2" />
    </application>
    </manifest>


    and build.gradle

    plugins {
    id "com.android.application"
    id "kotlin-android"
    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.xxxxx"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
    jvmTarget = '1.8'
    }

    sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
    applicationId "com.example.xxxxx"
    minSdkVersion flutter.minSdkVersion
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    }

    buildTypes {
    release {
    signingConfig signingConfigs.debug
    }
    }
    }

    flutter {
    source '../..'
    }

    dependencies {}

    Continue reading...

Compartilhe esta Página