Giter VIP home page Giter VIP logo

Comments (15)

bagus-setyawan avatar bagus-setyawan commented on June 11, 2024 3

Same problem here, anyone get this resolve ?

Edited:
I found another alternative to detect just mock Location (another detection are working), with the same way this plugin do, install Geolocator flutter plugin then use this code :

Future<bool> checkMockLocation() async {
    Position position = await Geolocator().getLastKnownPosition();
    return position.mocked;
  }

from trust_fall.

mateusschmidt avatar mateusschmidt commented on June 11, 2024 1

Same problem :/

E/TSLocationManager(22678): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Timer-1
E/TSLocationManager(22678): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:807)
E/TSLocationManager(22678): at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:740)
E/TSLocationManager(22678): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:156)
E/TSLocationManager(22678): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/TSLocationManager(22678): at com.anish.trust_fall.TrustFallPlugin$1.gotLocation(TrustFallPlugin.java:43)
E/TSLocationManager(22678): at com.anish.trust_fall.MockLocation.MockLocationCheck$GetLastLocation.run(MockLocationCheck.java:90)
E/TSLocationManager(22678): at java.util.TimerThread.mainLoop(Timer.java:562)
E/TSLocationManager(22678): at java.util.TimerThread.run(Timer.java:512)

from trust_fall.

iampopal avatar iampopal commented on June 11, 2024 1

I am also getting this error
Methods marked with @UiThread must be executed on the main thread. Current thread: Timer-0

when calling
bool canMockLocation = await TrustFall.canMockLocation;

from trust_fall.

anish-adm avatar anish-adm commented on June 11, 2024

@ENGR-ZEESHAN, Could you post output for flutter doctor please

from trust_fall.

zeexan-dev avatar zeexan-dev commented on June 11, 2024

@anish-adm
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.18362.267], locale en-PK)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.36.1)
[!] Connected device

from trust_fall.

alifgiant avatar alifgiant commented on June 11, 2024

@bagus-setyawan thanks a lot mate, this bug give me a headache.
Your code can bypass the bug

from trust_fall.

shinsenter avatar shinsenter commented on June 11, 2024

Same issue

E/AndroidRuntime( 6244): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Timer-1
E/AndroidRuntime( 6244):        at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:781)
E/AndroidRuntime( 6244):        at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:718)
E/AndroidRuntime( 6244):        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:144)
E/AndroidRuntime( 6244):        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:231)
E/AndroidRuntime( 6244):        at com.anish.trust_fall.TrustFallPlugin$1.gotLocation(TrustFallPlugin.java:43)
E/AndroidRuntime( 6244):        at com.anish.trust_fall.MockLocation.MockLocationCheck$GetLastLocation.run(MockLocationCheck.java:88)
E/AndroidRuntime( 6244):        at java.util.TimerThread.processTask(Timer.java:577)
E/AndroidRuntime( 6244):        at java.util.TimerThread.mainLoop(Timer.java:532)
E/AndroidRuntime( 6244):        at java.util.TimerThread.run(Timer.java:512)
I/Process ( 6244): Sending signal. PID: 6244 SIG: 9

from trust_fall.

Lzyct avatar Lzyct commented on June 11, 2024

@anish-adm could you check this Similiar issue, ?

i think this code make error

class GetLastLocation extends TimerTask {
        @Override
        public void run() {
            lm.removeUpdates(locationListenerGps);
            lm.removeUpdates(locationListenerNetwork);
            Location net_loc=null, gps_loc=null;
            if(gps_enabled)
                gps_loc=lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if(network_enabled)
                net_loc=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            //if there are both values use the latest one
            if(gps_loc!=null && net_loc!=null){
                if(gps_loc.getTime()>net_loc.getTime())
                    locationResult.gotLocation(gps_loc);
                else
                    locationResult.gotLocation(net_loc);
                return;
            }

            if(gps_loc!=null){
                locationResult.gotLocation(gps_loc);
                return;
            }
            if(net_loc!=null){
                locationResult.gotLocation(net_loc);
                return;
            }
            locationResult.gotLocation(null);
        }
    }

from trust_fall.

shinsenter avatar shinsenter commented on June 11, 2024

Still crashed with the latest Flutter version:

2020-09-07 16:35:51.858 19394-19683/com.mycompany.testapp E/AndroidRuntime: FATAL EXCEPTION: Timer-0
    Process: com.mycompany.testapp, PID: 19394
    java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Timer-0
        at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:992)
        at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:779)
        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:144)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:235)
        at com.anish.trust_fall.TrustFallPlugin$1.gotLocation(TrustFallPlugin.java:43)
        at com.anish.trust_fall.MockLocation.MockLocationCheck$GetLastLocation.run(MockLocationCheck.java:88)
        at java.util.TimerThread.processTask(Timer.java:577)
        at java.util.TimerThread.mainLoop(Timer.java:532)
        at java.util.TimerThread.run(Timer.java:512)
2020-09-07 16:35:52.020 19394-19505/com.mycompany.testapp D/FA: Event not sent since app measurement is disabled
2020-09-07 16:35:52.069 19394-19683/com.mycompany.testapp I/Process: Sending signal. PID: 19394 SIG: 9

from trust_fall.

sunnykinger avatar sunnykinger commented on June 11, 2024

Same problem here, anyone get this resolve ?

Edited:
I found another alternative to detect just mock Location (another detection are working), with the same way this plugin do, install Geolocator flutter plugin then use this code :

Future<bool> checkMockLocation() async {
    Position position = await Geolocator().getLastKnownPosition();
    return position.mocked;
  }

I think its now updated

Future<bool> checkMockLocation() async {
    Position position = await Geolocator.getLastKnownPosition();
    return position.isMocked;
  }

from trust_fall.

sunnykinger avatar sunnykinger commented on June 11, 2024

Same problem here, anyone get this resolve ?

Edited:
I found another alternative to detect just mock Location (another detection are working), with the same way this plugin do, install Geolocator flutter plugin then use this code :

Future<bool> checkMockLocation() async {
    Position position = await Geolocator().getLastKnownPosition();
    return position.mocked;
  }

try to execute this code after turning off and turning on location. It gives some kind of Exception.

from trust_fall.

 avatar commented on June 11, 2024

Is there any update on solving this error. I am also facing the same issue. I am on the latest build of TrustFall and flutter.

from trust_fall.

wisnuwiry avatar wisnuwiry commented on June 11, 2024

Same problem here, after building App in release mode.

from trust_fall.

bagus-setyawan avatar bagus-setyawan commented on June 11, 2024

@sunnykinger , @rp014947 , @wisnuwiry guys just use location plugin your own choice and make sure if permission permitted and get mocked properties from that, if you look into this project code you will notice that this is same way. Or you can make a fork and resolved the issue.

But once again users can pass this checker with many ways (rooted phone etc) so add another validations if your app consent is about real user's location.

from trust_fall.

thanhit93 avatar thanhit93 commented on June 11, 2024

Fix running on @UiThread :
@OverRide
public void onMethodCall(MethodCall call, @nonnull final Result result) {
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else if (call.method.equals("isJailBroken")) {
result.success(RootedCheck.isJailBroken(applicationContext));
} else if (call.method.equals("canMockLocation")) {
MockLocationCheck.LocationResult locationResult = new MockLocationCheck.LocationResult(){
@OverRide
public void gotLocation(final Location location){
android.os.Handler handler = new android.os.Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@OverRide
public void run() {
//Got the location!
if(location != null){
result.success(location.isFromMockProvider());
}else {
result.success(false);
}
}
});
}
};
MockLocationCheck mockLocationCheck = new MockLocationCheck();
mockLocationCheck.getLocation(applicationContext, locationResult);
}else if (call.method.equals("isRealDevice")) {
result.success(!EmulatorCheck.isEmulator());
}else if (call.method.equals("isOnExternalStorage")) {
result.success(ExternalStorageCheck.isOnExternalStorage(applicationContext));
}
else {
result.notImplemented();
}
}

Checking my github: thanhit93@8a24ca5

from trust_fall.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.