PokeGOAPI-Java icon indicating copy to clipboard operation
PokeGOAPI-Java copied to clipboard

Error when using GoogleAutoCredentialProvider

Open meher19 opened this issue 10 years ago • 43 comments

When i instanciate GoogleAutoCredentialProvider, i have this exception : java.lang.NoClassDefFoundError: Failed resolution of: Lsvarzee/gps/gpsoauth/Gpsoauth;

I tested this with an oldest jar of the api, it's working, so there is an issue in the latest version of the api.

This is my code :

OkHttpClient httpClient = new OkHttpClient();
        GoogleAutoCredentialProvider provider = new GoogleAutoCredentialProvider(httpClient, username, password);
        PokemonGo go = new PokemonGo(provider, httpClient);

meher19 avatar Aug 14 '16 09:08 meher19

Ok so the API is still not working ?

meher19 avatar Aug 18 '16 11:08 meher19

Can you reopen the issue https://github.com/Grover-c13/PokeGOAPI-Java/issues/513 ? Because the problem is still not resolved.

meher19 avatar Aug 18 '16 11:08 meher19

You need to add a delay between calls.

This is definitely not the API to use for learning gradle or Java. If you are unfamiliar with either, it would be much better to familiarize yourself with both and come back when you are ready. Time spent trying to diagnose personal implementation issues is taken directly from the time spent improving the API, possibly even to prevent them. Just something to consider.

AbandonedCart avatar Aug 18 '16 12:08 AbandonedCart

I don't like the way you talk to me, i'm a Java and Maven expert, but i never used Gradle before. My objective is not to learn programming but to create an Android app. Some problems i reported are not a personal implementation issues, so it helps improving the API and resolve bugs. For personal implementation questions : if you have no time to respond to them just don't do it, it's better than being disagreeable

I already have a one second delay between calls, so i insist about the existance of an issue.

meher19 avatar Aug 18 '16 12:08 meher19

Your issues so far have been with not following the README, so it is not unrealistic to think you may be inexperienced. If you are an expert, then I will leave it in your capable hands to diagnose the issue and propose a solution. Until then, it has not been reproduced by enough users to suggest it is an issue with the API and not something in your personal implementation.

AbandonedCart avatar Aug 18 '16 12:08 AbandonedCart

I have got the same code working in the past, until the Niantinc server update which broke tha API, i reported this issue in https://github.com/Grover-c13/PokeGOAPI-Java/issues/513. The server update needed some changes in the API to (supposed) make it work again, but even after updating the library the problem still not resolved. Check the https://github.com/Grover-c13/PokeGOAPI-Java/issues/513 history, you will see there is 3 other users experiencing the same issue, no one of them have resolved his problem. So i'm far being the only one experiencing this issue, you have to check all the history before to say sush things.

meher19 avatar Aug 18 '16 13:08 meher19

Maybe there server wants the correct sensor infos.

FabianTerhorst avatar Aug 18 '16 13:08 FabianTerhorst

@FabianTerhorst maybe, after last updates the official app is now checking if the fake gps mode is enabled in the device settings, if true the server send back an empty data, so we need to know which attribute the server uses to check this, are you sure this attribute is in the SensorInfo object ?

meher19 avatar Aug 18 '16 13:08 meher19

no its not. But we are faking an ios device so we don´t need this.

FabianTerhorst avatar Aug 18 '16 13:08 FabianTerhorst

@meher19 I have checked the history. While I understand you may be hostile over how you took my original comment, you also have to consider that 3 users experiencing a similar issue is still a localized issue. The probability of 3 in 100 people doing the same thing incorrectly is still quite high.

The server does not need an attribute to check if fake GPS is enabled on the device. That is a simple matter of whether or not sensor info exists according to the device sending it.

AbandonedCart avatar Aug 18 '16 14:08 AbandonedCart

This is the actual state of my code :

DeviceInfo deviceInfo = DeviceInfo.DEFAULT;
        go.setDeviceInfo(deviceInfo);
        SensorInfo sensorInfo = new SensorInfo();
        sensorInfo.setAngleNormalizedZ(0);
        go.setSensorInfo(sensorInfo);

If you have any suggestion i can try it.

meher19 avatar Aug 18 '16 14:08 meher19

Testing checklist:

  • Add a delay between login and first call (this includes something trivial, such as username)
  • Increase the delay between calls to 10 seconds (the minimum for map calls)
  • Make a single call for objects (or call the objects as a single object and then separate locally)
  • Set device information before making the first call
  • Leave time between tests where you do not connect at all (Official client or test code)
  • Try alternate accounts and IPs (such as connecting through wifi and 4g)

If you get positive results at any point, then you know where the issue lies.

AbandonedCart avatar Aug 18 '16 14:08 AbandonedCart

@meher19 i don´t have any jailbreaked ios device to get better informations for the sensorinfos. I just know there are incomplete.

FabianTerhorst avatar Aug 18 '16 14:08 FabianTerhorst

@LoungeKatt I increased the delays to 10 seconds, but still not working, this is my full code :

public List<EncounterResult> lookupPoke(String username, String password) throws InterruptedException, LoginFailedException, RemoteServerException, Exception, RuntimeException {
        OkHttpClient httpClient = new OkHttpClient();

        GoogleAutoCredentialProvider provider = new GoogleAutoCredentialProvider(httpClient, username, password);

        PokemonGo go = new PokemonGo(provider, httpClient);

        SECONDS.sleep(10);

        DeviceInfo deviceInfo = DeviceInfo.DEFAULT;
        go.setDeviceInfo(deviceInfo);

        SensorInfo sensorInfo = new SensorInfo();
        sensorInfo.setAngleNormalizedZ(0);
        go.setSensorInfo(sensorInfo);

        // After this you can access the api from the PokemonGo instance :
        go.setLocation(location.getLongitude(), location.getLatitude(), 0); // set your position to get stuff around (altitude is not needed, you can use 1 for exemple)
        List<CatchablePokemon> catchablePokemon = go.getMap().getCatchablePokemon(); // get all currently catchables pokemons around you
        List<EncounterResult> encounterResults = new ArrayList<EncounterResult>();

        for (CatchablePokemon cp : catchablePokemon) {
            // You need to Encounter first.
            EncounterResult encResult = (EncounterResult) cp.encounterPokemon();
            // if encounter was succesful, catch
            if (encResult.wasSuccessful()) {
                encounterResults.add(encResult);
            }
            SECONDS.sleep(10);
        }

        return encounterResults; // get all currently catchables pokemons around you
    }

meher19 avatar Aug 18 '16 14:08 meher19

Can you try to remove the sensorinfo set, because there are not fully set.

FabianTerhorst avatar Aug 18 '16 14:08 FabianTerhorst

public List<EncounterResult> lookupPoke(String username, String password) throws InterruptedException, LoginFailedException, RemoteServerException, Exception, RuntimeException {
        OkHttpClient httpClient = new OkHttpClient();

        GoogleAutoCredentialProvider provider = new GoogleAutoCredentialProvider(httpClient, username, password);

        PokemonGo go = new PokemonGo(provider, httpClient);
        DeviceInfo deviceInfo = DeviceInfo.DEFAULT;
        go.setDeviceInfo(deviceInfo);
        SensorInfo sensorInfo = new SensorInfo();
        sensorInfo.setAngleNormalizedZ(0);
        go.setSensorInfo(sensorInfo);

        SECONDS.sleep(10);

        // After this you can access the api from the PokemonGo instance :
        go.setLocation(location.getLongitude(), location.getLatitude(), 15); // set your position to get stuff around (altitude is not needed, you can use 1 for exemple)

        SECONDS.sleep(10);

        List<CatchablePokemon> catchablePokemon = go.getMap().getCatchablePokemon(); // get all currently catchables pokemons around you
        List<EncounterResult> encounterResults = new ArrayList<EncounterResult>();

        SECONDS.sleep(10);

        for (CatchablePokemon cp : catchablePokemon) {
            // You need to Encounter first.
            EncounterResult encResult = (EncounterResult) cp.encounterPokemon();
            // if encounter was succesful, catch
            if (encResult.wasSuccessful()) {
                encounterResults.add(encResult);
            }
            SECONDS.sleep(10);
        }

        return encounterResults; // get all currently catchables pokemons around you
    }

AbandonedCart avatar Aug 18 '16 14:08 AbandonedCart

set location is not a network call or?

FabianTerhorst avatar Aug 18 '16 14:08 FabianTerhorst

It's not. It sets it for the next call. It's not production code, just testing ridiculous delays.

AbandonedCart avatar Aug 18 '16 14:08 AbandonedCart

location is set by another method, it gets current gsp location from my android device which i faked to be sure to have some pokemons. I checked location objet in debug it contains the good value.

@FabianTerhorst i removed SensorInfo still not working. @LoungeKatt i tested your code always 0 data returned.

meher19 avatar Aug 18 '16 15:08 meher19

for me its working with the sample code.

FabianTerhorst avatar Aug 18 '16 15:08 FabianTerhorst