Skip to content

License Validation Failure in release Mode #1608

@david-inceptives

Description

@david-inceptives

Required Reading

  • Confirmed

Plugin Version

flutter_background_geolocation: ^4.17.1

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Redmi Note 11

Device operating-systems(s)

Android 13

What do you require assistance about?

I added a license key for android in manifest
Order # 14812
I am currently using New Key
When I build the release, install and run the app, I see a toast with the letters "License Verification Failed

[Optional] Plugin Code and/or Config

Future<void> _configureBackgroundGeolocation() async {
    await bg.BackgroundGeolocation.ready(bg.Config(
      reset: true,
      debug: false,
      logLevel: bg.Config.LOG_LEVEL_VERBOSE,

      // Force continuous updates
      desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
      distanceFilter: 10,
      locationUpdateInterval: 0,
      fastestLocationUpdateInterval: 0,

      // Background / termination handling
      stopOnTerminate: false,
      startOnBoot: true,
      enableHeadless: true,

      // Prevent iOS from pausing automatically
      pausesLocationUpdatesAutomatically: false,
      preventSuspend: true, // iOS only

      disableMotionActivityUpdates: false,
      stopTimeout: 5,
      locationAuthorizationRequest: 'Always',
      backgroundPermissionRationale: bg.PermissionRationale(
        title: "Allow DPS Airem to access your location even when closed or not in use.",
        message: "DPS Airem collects location data to support tracking even when the app is closed.",
        positiveAction: 'Allow',
        negativeAction: 'Deny',
      ),

      // Android foreground service
      foregroundService: true,
      notification: bg.Notification(
        title: "DPS Airem Tracking Active",
        text: "Location service is running in background.",
        channelName: "Location Tracking",
        smallIcon: "mipmap/notification_icon",
        priority: bg.Config.NOTIFICATION_PRIORITY_HIGH,
      ),

      disableElasticity: true,
      geofenceProximityRadius: 1000,
      heartbeatInterval: 60,
    ));

    // Listen for location updates
    bg.BackgroundGeolocation.onLocation(
          (bg.Location location) async {
        double? lat = location.coords.latitude;
        double? lng = location.coords.longitude;
        try {

          FirestoreController.instance.saveUserTrackingData(
              id:userModel.value.user!.id,
              name:userModel.value.user!.name,
              image:userModel.value.user!.details!.image,
              role:userModel.value.user!.details!.isEmployee,
              lat:lat,
              lng:lng,
              location: shiftData.value != null?shiftData.value!.location!.address!:"-",
              checkInTime:  currentTime!=null?DateTimeUtil.formatDateTime(currentTime,outputDateTimeFormat: DateTimeUtil.localTimeFormat2,isutc: true):"-",
              isCheckIn: true);

          print('✅ Location saved to Firebase');
        } catch (e) {
          print('❌ Error saving location: $e');
        }
      },
          (bg.LocationError error) {
        print('[onLocation] ERROR: $error');
      },


    );

  }

[Optional] Relevant log output

Manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.app.dpsairem">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

    <application
        tools:replace="android:label"
        android:label="DPS Airem"
        android:name="${applicationName}"
        android:hardwareAccelerated="true"
        android:roundIcon="@mipmap/round_launcher"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true"
        android:enableOnBackInvokedCallback="true"
        android:requestLegacyExternalStorage="true"
        android:allowBackup="false"
        android:fullBackupContent="false"
        android:theme="@style/LaunchTheme">
        <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">

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

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="nosensor"
            android:windowLayoutInDisplayCutoutMode="never"
            android:theme="@style/Ecift.CropTheme"/>

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

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="high_importance_channel" />

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@mipmap/notification_icon" />

        <meta-data android:name="com.google.android.geo.API_KEY"
            android:value="AIz********DODr74az0"/>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">

            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

        <meta-data
            android:name="com.transistorsoft.locationmanager.license"
            android:value="@string/transistor_license" />
    </application>

    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
    </queries>
</manifest>



App Gradle


import java.util.Properties
import java.io.FileInputStream

plugins {
    id("com.android.application")
    id("kotlin-android")
    id("dev.flutter.flutter-gradle-plugin")
    id("com.google.gms.google-services")
}

val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

val backgroundGeolocation = project(":flutter_background_geolocation")
apply { from("${backgroundGeolocation.projectDir}/background_geolocation.gradle") }
android {
    namespace = "com.app.dpsairem"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = "27.0.12077973"

    compileOptions {
        isCoreLibraryDesugaringEnabled = true
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }

    defaultConfig {
        applicationId = "com.app.dpsairem"
        minSdk = 23
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    signingConfigs {
        create("release") {
            keyAlias = keystoreProperties["keyAlias"] as String
            keyPassword = keystoreProperties["keyPassword"] as String
            storeFile = keystoreProperties["storeFile"]?.let { file(it) }
            storePassword = keystoreProperties["storePassword"] as String
        }
    }
    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.getByName("debug")
            isMinifyEnabled = true
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
            signingConfig = signingConfigs.getByName("release")
            isShrinkResources = false   // <-- REQUIRED !!!


        }
    }

    dependencies {
        implementation("androidx.window:window:1.0.0")
        implementation("androidx.window:window-java:1.0.0")
        coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
    }
}

flutter {
    source = "../.."
}

dependencies {
    implementation(platform("com.google.firebase:firebase-bom:33.15.0"))
    implementation("com.google.firebase:firebase-analytics")
    implementation("com.google.firebase:firebase-crashlytics")
}


Android Gradle

plugins {
    id("com.google.gms.google-services") version "4.4.2" apply false

}
allprojects {
    ext {
        set("appCompatVersion", "1.4.2")             // or higher / as desired
        set("playServicesLocationVersion", "21.3.0") // or higher / as desired
    }
    repositories {
        google()
        mavenCentral()
        // [required] background_geolocation
        maven(url = "${project(":flutter_background_geolocation").projectDir}/libs")
        maven(url = "https://developer.huawei.com/repo/")
        maven(url = "${project(":background_fetch").projectDir}/libs")
    }
}

val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
    val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
    project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register<Delete>("clean") {
    delete(rootProject.layout.buildDirectory)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions