Closed luiscelanomrb closed 3 years ago
When you have a problem, observe $ adb logcat *S TSLocationManager:V flutter:V
Observing a release build on my OnePlus A5010 @ 9.0.0 and the /example app running in the background, I see print
statements rendered to adb logcat *:S TSLocationManager:V flutter:V
:
11-26 11:05:24.093 15491 15596 I flutter : [location] - [Location {odometer: 31479.5, activity: {confidence: 100, type: still}, extras: {foo: bar}, timestampMeta: {elapsedRealtime: 2838292176, time: 1606406722938, systemTime: 1606406724088, systemClockElaspsedRealtime: 2838293326}, battery: {level: 1.0, is_charging: true}, uuid: 2a1322b5-ef29-42d9-8a29-837f62d066a6, coords: {altitude: 43.9, heading: 210.74, latitude: 45.5189445, accuracy: 17.4, heading_accuracy: -1.0, altitude_accuracy: 2.0, speed_accuracy: -1.0, speed: 0.36, longitude: -73.6004967}, is_moving: true, timestamp: 2020-11-26T16:05:22.938Z}]
At the moment to get $ adb logcat *S TSLocationManager:V flutter:V
on Samsung SM-A515F v10.0, we didn´t have any result about location or any sensor.
when I log on release mode I got this exception.
11-26 10:28:27.285 11378 11378 E TSLocationManager: ‼️ Failed to deduce Application's BuildConfig class for package name:com.twowheelstogo.twtogoadmin or com.twowheelstogo 11-26 10:28:27.285 11378 11378 W System.err: java.lang.ClassNotFoundException: com.twowheelstogo.twtogoadmin.BuildConfig 11-26 10:28:27.285 11378 11378 W System.err: at java.lang.Class.classForName(Native Method) 11-26 10:28:27.286 11378 11378 W System.err: at java.lang.Class.forName(Class.java:454) 11-26 10:28:27.286 11378 11378 W System.err: at java.lang.Class.forName(Class.java:379) 11-26 10:28:27.286 11378 11378 W System.err: at com.transistorsoft.locationmanager.util.a.d(Unknown Source:37) 11-26 10:28:27.286 11378 11378 W System.err: at com.transistorsoft.locationmanager.util.a.a(Unknown Source:11) 11-26 10:28:27.286 11378 11378 W System.err: at com.transistorsoft.locationmanager.util.a.b(Unknown Source:0) 11-26 10:28:27.286 11378 11378 W System.err: at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.isMainActivityActive(Unknown Source:103)
Now you see why you must always monitor $ adb logcat
.
You have confusion between your AndroidManifest
and applicationId
in app/build.gradle
.
Post the <manifest>
element in your AndroidManifest.xml
, eg:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.transistorsoft.flutterbackgroundgeolocationexample">
Post your app/build.gradle
.
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.twowheelstogo.twtogoadmin">
app/build.gradle
apply plugin: 'com.android.application'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
Project background_geolocation = project(':flutter_background_geolocation')
apply from: "${background_geolocation.projectDir}/background_geolocation.gradle"
if (flutterRoot == null) {
throw new 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 {
// compileSdkVersion 29
compileSdkVersion rootProject.ext.compileSdkVersion
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.twowheelstogo.twtogoadmin"
multiDexEnabled true
minSdkVersion 24
// targetSdkVersion 29
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
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.release
signingConfig signingConfigs.debug
shrinkResources false
proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.multidex:multidex:2.0.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
}
package
in AndroidManifest
matches applicationId
in build.gradle
.
You're not supposed to use both versions of multidex
(androidX + non-androidx). Get rid of this:
-implementation 'com.android.support:multidex:1.0.3'
Clean your build:
$ cd android
$ ./gradlew clean
after build.gradle
changes, we still having the same problem.
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.5.0'
// implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.multidex:multidex:2.0.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
}
$ ./gradlew clean
Starting a Gradle Daemon, 1 busy and 2 incompatible Daemons could not be reused, use --status for details
Configure project :app
[flutter_background_geolocation] Purging debug resources in release build
Plugin project :location_web not found. Please update settings.gradle.
Configure project :qr_code_scanner
useNewCruncher has been deprecated. It will be removed in a future version of the gradle plugin. New cruncher is now always enabled.
BUILD SUCCESSFUL in 43s
24 actionable tasks: 1 executed, 23 up-to-date
when I run adb logcat *:S TSLocationManager:V flutter:V
I got this exception:
11-26 11:08:18.902 619 1308 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent onOneShot]
11-26 11:08:18.902 619 1308 I TSLocationManager: ╔═════════════════════════════════════════════
11-26 11:08:18.902 619 1308 I TSLocationManager: ║ ⏰ OneShot event fired: TERMINATE_EVENT
11-26 11:08:18.902 619 1308 I TSLocationManager: ╠═════════════════════════════════════════════
11-26 11:08:18.916 619 1308 E TSLocationManager: [c.t.locationmanager.util.a d]
11-26 11:08:18.916 619 1308 E TSLocationManager: ‼️ Failed to deduce Application's BuildConfig class for package name:com.twowheelstogo.twtogoadmin or com.twowheelstogo
11-26 11:08:18.916 619 1308 W System.err: java.lang.ClassNotFoundException: com.twowheelstogo.twtogoadmin.BuildConfig
11-26 11:08:18.918 619 1308 W System.err: at java.lang.Class.classForName(Native Method)
11-26 11:08:18.918 619 1308 W System.err: at java.lang.Class.forName(Class.java:454)
11-26 11:08:18.919 619 1308 W System.err: at java.lang.Class.forName(Class.java:379)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.util.a.d(Unknown Source:37)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.util.a.a(Unknown Source:11)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.util.a.b(Unknown Source:0)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation.isMainActivityActive(Unknown Source:103)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.event.TerminateEvent.<init>(Unknown Source:16)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.scheduler.ScheduleEvent.onOneShot(Unknown Source:47)
11-26 11:08:18.919 619 1308 W System.err: at com.transistorsoft.locationmanager.scheduler.ScheduleJobService$a.run(Unknown Source:41)
11-26 11:08:18.919 619 1308 W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
11-26 11:08:18.919 619 1308 W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
11-26 11:08:18.919 619 1308 W System.err: at java.lang.Thread.run(Thread.java:919)
11-26 11:08:18.919 619 1308 W System.err: Caused by: java.lang.ClassNotFoundException: com.twowheelstogo.twtogoadmin.BuildConfig
11-26 11:08:18.919 619 1308 W System.err: ... 13 more
11-26 11:08:18.921 619 1308 D TSLocationManager: [c.t.l.event.TerminateEvent <init>]
11-26 11:08:18.921 619 1308 D TSLocationManager: ℹ️ TERMINATE_EVENT ignored (MainActivity is still active).
Can you give me access to your application repo?
I sent an invitation to repo.
To access to background service go to lib/services/geoposition_background.dart
Something unusual is happening with your app, possibly related to your gradle-tools version.
Try this.
android/app/proguard-rules.pro
.-keep public class com.twowheelstogo.twtogoadmin.BuildConfig {*; }
android/app/build.gradle
add the following line to your buildTypes/release
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
shrinkResources false
+ proguardFiles "proguard-rules.pro"
proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
}
}
Hi Christopher, Thank you for your quick response. We will do accordantly. I will keep you posted of our progress once we finish our testing. Kind regards team TwoWheelstogo
Hi Chris, after a few days of several tests with some users, we didn´t have any response yet, I don´t know if I skipped some important step before APK release was created.
I upgraded my gradle tools version to 6.5.
------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_261 (Oracle Corporation 25.261-b12)
OS: Windows 10 10.0 amd64
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
Your Environment
flutter doctor
):[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [√] Android Studio (version 4.0) [√] VS Code (version 1.51.1) [!] Connected device ! No devices available
! Doctor found issues in 1 category.
Expected Behavior
Expected get response from
onLocation
event when apk is generated to launch on Android Platform.Actual Behavior
When release apk is generated to launch on Android Platform,
onLocation
doesn´t return nothing, indebug
orrelease
mode,onLocation
event works fine.Context
Actually we are trying to capture current user location to manage tracking for each 45 meters
Release logs
At this image, we can see if
onLocation
callback is called with a boolean expresion, in release Android Platform mode that expresion as always false, this means thatonLocation
isn´t called.