Hi,

I've downloaded and installed Android Studio (ver 1.2.1.1) and JDK pacakge 
as well.  The dev environment seems to has been set up correct.  And I'd 
like to hack my first super simple Android app.  It would perform only two 
functions.  First, connect to a URL and get its content (data records), 
then display them.  That is it, nothing fancy.  I've watched a relevant 
Youtube video, created the main java code using AsyncTask
and the supporting connection java code as well. 

Running the app generated two errors.  
The 1st one is: "error: <identifier> expected", source code: httpGet = new 
(url);
// fyi, url has been defined already

And the 2nd error is:
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.

And here's the full source code
----------------------------------------------
package com.mydomain.app_fc;

/**
 * Created by dli on 6/7/2015.
 */

import android.util.Log;

import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;

import java.io.IOException;
import java.net.URL;

/**
 * Created by dli on 6/6/2015.
 */
public static class appConnect {
    public JSONArray getStuff() {
        // URL to get fc;
        String url = 
"http://www.mydomain.com/stuff/mystuff.cfc?wsdl&method=getFCs";;
        // HttpURLConnection urlConnection = (HttpURLConnection) 
url.openConnection();
        // get HTTP response object
        //
        HttpEntity = null;
        HttpResponse = null;

        try {
            httpClient = new DefaultHttpClient();
            //  HttpGet httpGet = new HttpGet(url);
            httpGet = new (url);
           // HttpGet request = new HttpGet(url);
            httpResponse = httpClient.execute(httpGet);
           // httpResponse = urlConnection.getContent();
            HttpEntity = httpResponse.getEntity();

        } catch (clientProtocoException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // convert http entity into JSON array
        JSONArray jsonarray = null;
        if (HttpEntity != null) {
            try {
                String entityResponse = toString(HttpEntity);
                // debug
                Log.e("Entity Response : ", entityResponse);
                jasonarray = new JSONArray(entityReponse);
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
        return jasonarray;
    }
}


package com.mydomain.app_fc;

/**
 * Created by dli on 6/7/2015.
 */

import android.util.Log;

import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;

import java.io.IOException;
import java.net.URL;

/**
 * Created by dli on 6/6/2015.
 */
public static class appConnect {
    public JSONArray getStuff() {
        // URL to get fc;
        String url = 
"http://www.mydomain.com/stuff/mystuff.cfc?wsdl&method=getFCs";;
        // HttpURLConnection urlConnection = (HttpURLConnection) 
url.openConnection();
        // get HTTP response object
        //
        HttpEntity = null;
        HttpResponse = null;

        try {
            httpClient = new DefaultHttpClient();
            //  HttpGet httpGet = new HttpGet(url);
            httpGet = new (url);
           // HttpGet request = new HttpGet(url);
            httpResponse = httpClient.execute(httpGet);
           // httpResponse = urlConnection.getContent();
            HttpEntity = httpResponse.getEntity();

        } catch (clientProtocoException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // convert http entity into JSON array
        JSONArray jsonarray = null;
        if (HttpEntity != null) {
            try {
                String entityResponse = toString(HttpEntity);
                // debug
                Log.e("Entity Response : ", entityResponse);
                jasonarray = new JSONArray(entityReponse);
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
        return jasonarray;
    }
}


How do we fix it?  
Many thanks.



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to