Aws-sdk-android: [API GATEWAY][ANDROID] Force close when try to Invoke method

Created on 24 Apr 2016  路  7Comments  路  Source: aws-amplify/aws-sdk-android

I got a problem when i try to set up the client, get the toString() failure in the factory.build.
Method threw 'java.lang.IllegalArgumentException' exception. Cannot evaluate $Proxy1.toString() then when i call

 ApiClientFactory factory = new ApiClientFactory();
        factory.apiKey("xXXxXXXXXXXxxxxXXxxXXXXxxxi");
        final APIGatewayPediuClient client = factory.build(APIGatewayPediuClient.class); // exeception threw here Cannot evaluate $Proxy1.toString()

and then i try get place Places place = client.placesGet(); force close happens

com.amazonaws.http.UrlHttpClient.createHttpResponse(UrlHttpClient.java:72)
at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:66)
at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.invoke(ApiClientHandler.java:91)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy1.placesGet(Unknown Source)
at net.devsoft.pediu.activity.HomeActivity$override.onCreate(HomeActivity.java:195)
at net.devsoft.pediu.activity.HomeActivity$override.access$dispatch(HomeActivity.java)

SDK version:

compile com.amazonaws:aws-android-sdk-core:2.2.6'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.6'
compile 'com.amazonaws:aws-android-sdk-apigateway-core:2.2.6'
compile 'com.google.code.gson:gson:1.7.2

already tried with aws verison 2.2.15, the SDK generate to Obj-C its working perfectly

Usage Question

Most helpful comment

The solution is put this code inside a AsyncTask.

        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {

                 ApiClientFactory factory = new ApiClientFactory();
                 factory.apiKey("xXXxXXXXXXXxxxxXXxxXXXXxxx");
                 final APIGatewayPediuClient client = factory.build(APIGatewayPediuClient.class); 
                Places place = client.placesGet();
                return null;
            }
        }.execute(); 

All 7 comments

I am getting the same problem over here. The IOS project it is working fine though.
I need to build the app in both plataforms, Someone Can help in this problem?
Really appreciate the help.

The solution is put this code inside a AsyncTask.

        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {

                 ApiClientFactory factory = new ApiClientFactory();
                 factory.apiKey("xXXxXXXXXXXxxxxXXxxXXXXxxx");
                 final APIGatewayPediuClient client = factory.build(APIGatewayPediuClient.class); 
                Places place = client.placesGet();
                return null;
            }
        }.execute(); 

Thanks, it works for me

i am facing same problem any other solution for this? aws api gateway shows exception like this Method threw 'java.lang.IllegalArgumentException' exception. Cannot evaluate $Proxy1.toString() without crashing please help

@miguelslemos Hi, Can you post your client interface here ?
I am getting the same problem even with the Async Task.

My client code is as follows ...

/**
* Client
*/
@com.amazonaws.mobileconnectors.apigateway.annotation.Service(endpoint = "myapi")
public interface HRISauthClient {

/**
 * @param request
 * @return ApiResponse
 */
com.amazonaws.mobileconnectors.apigateway.ApiResponse execute(com.amazonaws.mobileconnectors.apigateway.ApiClientFactory request);

/**
 * @return Output
 */
@com.amazonaws.mobileconnectors.apigateway.annotation.Operation(path = "/", method = "GET")
Empty rootGet();

}

@shaivyaaggarwal @jayabals28 Could you solve the issue? I'm facing the same despite I put the code in an AsyncTask block.

Why this is closed ?驴 I'm actually having the same isue:
Method threw 'com.amazonaws.mobileconnectors.apigateway.ApiClientException' exception. Cannot evaluate $Proxy1.toString()

My Code :
ApiClientFactory factory = new ApiClientFactory();
ApiRestClient client = factory.build(ApiRestClient.class);
new AsyncTask() {
@Override
protected Void doInBackground(Void... params) {
ResponseSchema r = client.usersGetProfileInfoGet("Marc");
Log.d(TAG, "RESPONSE --> " + r.getResponse());
return null;
}

    }.execute();

Also i'm getting null as response

Was this page helpful?
0 / 5 - 0 ratings