Autore Topic: Information:Gradle tasks [:app:assembleDebug]  (Letto 608 volte)

Offline Trinkwasser

  • Nuovo arrivato
  • *
  • Post: 32
  • Respect: 0
    • Mostra profilo
Information:Gradle tasks [:app:assembleDebug]
« il: 11 Settembre 2015, 19:33:27 CEST »
0
Quando ho provato a compilare la mia app, ho riscontrato questo errore che non riesco proprio a capire cosa sia

Codice: [Seleziona]
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable780Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:collectDebugMultiDexComponents
:app:packageAllDebugClassesForMultiDex FAILED
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/http/client/HttpRequestRetryHandler.class
Information:BUILD FAILED
Information:Total time: 2.124 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

stavo cercando di recuperare i dati di un database mysql traminte JSON

Codice (Java): [Seleziona]
package com.example.alessandro.celiachia;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.net.ParseException;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;

public class NewsActivity extends ListActivity {

    /* Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        String result = null;
        InputStream is = null;
        StringBuilder sb = null;
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        List<String> r = new ArrayList<String>();

        try{
            //http post
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://localhost/dashboard/news.php");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        }
        catch(Exception e){
            Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG).show();
        }

        //Convert response to string
        try
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));

            sb = new StringBuilder();

            String line = null;

            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }

            is.close();

            result = sb.toString();
        }
        catch(Exception e)
        {
            Toast.makeText(getBaseContext(),e.toString() ,Toast.LENGTH_LONG).show();
        }
        //END Convert response to string
        try{
            JSONArray jArray = new JSONArray(result);
            JSONObject json_data=null;
            for(int i=0;i<jArray.length();i++)
            {
                json_data = jArray.getJSONObject(i);
                r.add(json_data.getString("title"));
            }
            setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, r));
        }
        catch(JSONException e1){
            Toast.makeText(getBaseContext(),e1.toString() ,Toast.LENGTH_LONG).show();
        } catch (ParseException e1) {
            Toast.makeText(getBaseContext(),e1.toString() ,Toast.LENGTH_LONG).show();
        }

    }
}

Quando ho provato a testare l'app mi da questo errore, che non sono riuscito proprio a risolvere. Help me! Thanks

Offline pietroconti89

  • Utente normale
  • ***
  • Post: 164
  • Respect: +19
    • Mostra profilo
  • Dispositivo Android:
    Galaxy Note 3 N9005
  • Sistema operativo:
    Windows / Mac OSX
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #1 il: 11 Settembre 2015, 22:22:23 CEST »
0
Ciao ci sono diverse problematiche qui in mezzo .... innanzitutto non hai settato il layout  e poi per poter eseguire richieste che usino connettività internet devi x forza utilizzare processi separati .... a mio avviso il più semplice da implementare / gestire sono le asyntask .... oltre a questo bisognerebbe vedere anche il Gradle.... saluti
   

Quando ho provato a compilare la mia app, ho riscontrato questo errore che non riesco proprio a capire cosa sia

Codice: [Seleziona]
Information:Gradle tasks [:app:assembleDebug]
:appreBuild UP-TO-DATE
:appreDebugBuild UP-TO-DATE
:app:checkDebugManifest
:appreReleaseBuild UP-TO-DATE
:apprepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:apprepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:apprepareComAndroidSupportMultidex101Library UP-TO-DATE
:apprepareComAndroidSupportSupportV42301Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServices780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesAds780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesAnalytics780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesAppindexing780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesAppstate780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesCast780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesDrive780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesFitness780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesGames780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesIdentity780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesNearby780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesPanorama780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesPlus780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesSafetynet780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesVision780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesWallet780Library UP-TO-DATE
:apprepareComGoogleAndroidGmsPlayServicesWearable780Library UP-TO-DATE
:apprepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:approcessDebugManifest UP-TO-DATE
:approcessDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:approcessDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:collectDebugMultiDexComponents
:appackageAllDebugClassesForMultiDex FAILED
Error:Execution failed for task ':appackageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/http/client/HttpRequestRetryHandler.class
Information:BUILD FAILED
Information:Total time: 2.124 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

stavo cercando di recuperare i dati di un database mysql traminte JSON

Codice (Java): [Seleziona]
package com.example.alessandro.celiachia;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.net.ParseException;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;

public class NewsActivity extends ListActivity {

    /* Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        String result = null;
        InputStream is = null;
        StringBuilder sb = null;
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        List<String> r = new ArrayList<String>();

        try{
            //http post
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://localhost/dashboard/news.php");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        }
        catch(Exception e){
            Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG).show();
        }

        //Convert response to string
        try
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));

            sb = new StringBuilder();

            String line = null;

            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }

            is.close();

            result = sb.toString();
        }
        catch(Exception e)
        {
            Toast.makeText(getBaseContext(),e.toString() ,Toast.LENGTH_LONG).show();
        }
        //END Convert response to string
        try{
            JSONArray jArray = new JSONArray(result);
            JSONObject json_data=null;
            for(int i=0;i<jArray.length();i++)
            {
                json_data = jArray.getJSONObject(i);
                r.add(json_data.getString("title"));
            }
            setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, r));
        }
        catch(JSONException e1){
            Toast.makeText(getBaseContext(),e1.toString() ,Toast.LENGTH_LONG).show();
        } catch (ParseException e1) {
            Toast.makeText(getBaseContext(),e1.toString() ,Toast.LENGTH_LONG).show();
        }

    }
}

Quando ho provato a testare l'app mi da questo errore, che non sono riuscito proprio a risolvere. Help me! Thanks



Inviato dal mio SM-N9005 utilizzando Tapatalk
« Ultima modifica: 11 Settembre 2015, 22:24:52 CEST da pietroconti89 »

Offline Trinkwasser

  • Nuovo arrivato
  • *
  • Post: 32
  • Respect: 0
    • Mostra profilo
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #2 il: 12 Settembre 2015, 13:28:08 CEST »
0
Ho provato ad usare processi separati come hai detto tu, ma l'errore si presenta sempre e comunque.
In ogni caso il codice è questo:

JSONfuncition.java

Codice (Java): [Seleziona]
import android.util.Log;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;

/**
 * Created by alessandro on 12/09/15.
 */

public class JSONfunctions {

    public static JSONObject getJSONfromURL(String url) {
        InputStream is = null;
        String result = "";
        JSONObject jArray = null;

        // Download JSON data from URL
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();

        } catch (Exception e) {
            Log.e("log_tag", "Error in http connection " + e.toString());
        }

        // Convert response to string
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
        } catch (Exception e) {
            Log.e("log_tag", "Error converting result " + e.toString());
        }

        try {
            jArray = new JSONObject(result);
        } catch (JSONException e) {
            Log.e("log_tag", "Error parsing data " + e.toString());
        }

        return jArray;
    }
}

NewsActivity.java

Codice (Java): [Seleziona]
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class NewsActivity extends ListActivity {

    // Progress Dialog
    private ProgressDialog pDialog;

    // Creating JSON Parser object
    JSONfunctions jParser = new JSONfunctions();

    ArrayList<HashMap<String, String>> newsList;

    // url to get all products list
    private static String url_all_news = "http://localhost/dashboard/get_all_news.php";

    // JSON Node names
    private static final String TAG_SUCCESS = "success";
    private static final String TAG_NEWS = "news";
    private static final String TAG_ID = "id";
    private static final String TAG_TITLE = "title";

    // products JSONArray
    JSONArray news = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);

        // Hashmap for ListView
        newsList = new ArrayList<HashMap<String, String>>();

        // Loading products in Background Thread
        new LoadAllNews().execute();

        // Get listview
        ListView lv = getListView();

    }

    // Response from Edit Product Activity
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // if result code 100
        if (resultCode == 100) {
            // if result code 100 is received
            // means user edited/deleted product
            // reload this screen again
            Intent intent = getIntent();
            finish();
            startActivity(intent);
        }

    }

    /**
     * Background Async Task to Load all product by making HTTP Request
     * */

    class LoadAllNews extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(NewsActivity.this);
            pDialog.setMessage("Loading news. Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(false);
            pDialog.show();
        }

        /**
         * getting All products from url
         * */

        protected String doInBackground(String... args) {
            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            // getting JSON string from URL
            JSONObject json = jParser.getJSONfromURL(url_all_news);

            // Check your log cat for JSON reponse
            Log.d("All News: ", json.toString());

            try {
                // Checking for SUCCESS TAG
                int success = json.getInt(TAG_SUCCESS);

                if (success == 1) {
                    // products found
                    // Getting Array of Products
                    news = json.getJSONArray(TAG_NEWS);

                    // looping through All Products
                    for (int i = 0; i < news.length(); i++) {
                        JSONObject c = news.getJSONObject(i);

                        // Storing each json item in variable
                        String id = c.getString(TAG_ID);
                        String title = c.getString(TAG_TITLE);

                        // creating new HashMap
                        HashMap<String, String> map = new HashMap<String, String>();

                        // adding each child node to HashMap key => value
                        map.put(TAG_ID, id);
                        map.put(TAG_TITLE, title);

                        // adding HashList to ArrayList
                       newsList.add(map);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        /**
         * After completing background task Dismiss the progress dialog
         * **/

        protected void onPostExecute(String file_url) {
            // dismiss the dialog after getting all products
            pDialog.dismiss();
            // updating UI from Background Thread
            runOnUiThread(new Runnable() {
                public void run() {
                    /**
                     * Updating parsed JSON data into ListView
                     * */

                    ListAdapter adapter = new SimpleAdapter(NewsActivity.this, newsList, R.layout.list_news_item,
                            new String[] { TAG_ID,TAG_TITLE}, new int[] { R.id.id, R.id.title });
                    // updating listview
                    setListAdapter(adapter);
                }
            });

        }

    }
}

activity_news.xml

Codice (XML): [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical">

    <!-- Main ListView
        Always give id value as list(@android:id/list_view_news)
   -->
    <ListView
       android:id="@+id/list_view_news"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"/>

</LinearLayout>

list_news_item.xml

Codice (XML): [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical" >

    <!-- Product id (pid) - will be HIDDEN - used to pass to other activity -->
    <TextView
       android:id="@+id/id"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:visibility="gone" />

    <!-- Name Label -->
    <TextView
       android:id="@+id/title"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:paddingTop="6dip"
       android:paddingLeft="6dip"
       android:textSize="17dip"
       android:textStyle="bold" />

</LinearLayout>

Offline tonno16

  • Utente storico
  • *****
  • Post: 1228
  • Respect: +59
    • Mostra profilo
  • Dispositivo Android:
    moto g
  • Play Store ID:
    Diego Tonini
  • Sistema operativo:
    OpenSuse
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #3 il: 12 Settembre 2015, 13:44:55 CEST »
0
Guarda Se può esserti d'aiuto

Post unito: 12 Settembre 2015, 13:45:06 CEST
gradle - Commons-Io Duplicate Entry Error Using Robospice and Android Studio - Stack Overflow

Offline Trinkwasser

  • Nuovo arrivato
  • *
  • Post: 32
  • Respect: 0
    • Mostra profilo
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #4 il: 12 Settembre 2015, 15:30:19 CEST »
0
Ho appena provato, ma niente! Grazie comunque dell'aiuto, spero di risolvere presto

Offline tonno16

  • Utente storico
  • *****
  • Post: 1228
  • Respect: +59
    • Mostra profilo
  • Dispositivo Android:
    moto g
  • Play Store ID:
    Diego Tonini
  • Sistema operativo:
    OpenSuse
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #5 il: 12 Settembre 2015, 15:52:07 CEST »
0
Io consiglio di usare okhttp o asynkhttp e Gson.
2 librerie che funzionano benissimo e con poche righe

Offline Trinkwasser

  • Nuovo arrivato
  • *
  • Post: 32
  • Respect: 0
    • Mostra profilo
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #6 il: 12 Settembre 2015, 21:42:33 CEST »
0
Non le conosco, sapresti fornirmi qualche dettaglio in più o ancora meglio una guida?

Offline tonno16

  • Utente storico
  • *****
  • Post: 1228
  • Respect: +59
    • Mostra profilo
  • Dispositivo Android:
    moto g
  • Play Store ID:
    Diego Tonini
  • Sistema operativo:
    OpenSuse
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #7 il: 13 Settembre 2015, 00:49:34 CEST »
0
No. Se vai sul sito ufficiale (USA pure la pagina di github) ci sono dei piccoli esempi.
Gson ti permette di avere un oggetto custom java a partire sa una stringa json.

Offline Trinkwasser

  • Nuovo arrivato
  • *
  • Post: 32
  • Respect: 0
    • Mostra profilo
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #8 il: 13 Settembre 2015, 09:56:19 CEST »
0
Grazieeee tante, controllo subito!

Offline tonno16

  • Utente storico
  • *****
  • Post: 1228
  • Respect: +59
    • Mostra profilo
  • Dispositivo Android:
    moto g
  • Play Store ID:
    Diego Tonini
  • Sistema operativo:
    OpenSuse
Re:Information:Gradle tasks [:app:assembleDebug]
« Risposta #9 il: 13 Settembre 2015, 10:01:53 CEST »
0
Guarda:

Codice (Java): [Seleziona]
import org.json.*;
import com.loopj.android.http.*;

class TwitterRestClientUsage {
    public void getPublicTimeline() throws JSONException {
        TwitterRestClient.get("statuses/public_timeline.json", null, new JsonHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                // If the response is JSONObject instead of expected JSONArray
            }
           
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONArray timeline) {
                // Pull out the first event on the public timeline
                JSONObject firstEvent = timeline.get(0);
                String tweetText = firstEvent.getString("text");

                // Do something with the response
                System.out.println(tweetText);
            }
        });
    }
}


viene invocato il metodo a seconda che si tratti di una collezzione o di un unico oggetto. Es catalogo libri per la collezione o una squadra per un oggetto.