Hello Android Tutorial su Debian Testing

Posted by Dario Santamaria Sun, 17 Oct 2010 11:54:00 GMT

Questo tutorial ha lo scopo di guidarvi passo passo nella creazione e installazione di un’applicazione (Hello Android) all’interno di un dispositivo Android disponendo di un PC con distribuzione Debian Testing.

Di che cosa abbiamo bisogno:

  • Un IDE per sviluppare la nostra app – Eclipse
  • Android SDK – presso Google
  • Un plugin per l’IDE (ADT) per poter creare il nostro package .apk
  • Uno smartphone Android – Motorola Flipout

Intanto segnalo il fatto che si potrebbe utilizzare come IDE Netbeans (ne sono un utilizzatore convinto), ma il problema è che nei repositories Debian siamo attualmente fermi alla versione 6.0.1 che non supporta l’attuale plugin nbandroid :-(

Iniziamo a configurare la nostra distro per ottenere il risultato desiderato: creare un package .apk da inviare al nostro smartphone.

1. Eclipse IDE

Diamo da riga di comando:

$ apt-get install eclipse

e verranno installati in automatico tutti i pacchetti necessari (tra cui eclipse-jdt eclipse-pde eclipse-platform eclipse-platform-data eclipse-plugin-cvs eclipse-rcp).

2. Android SDK

Preleviamo da developer.android.com il pacchetto .tgz per la nostra piattaforma:

$ wget http://dl.google.com/android/android-sdk_r07-linux_x86.tgz

ed estraiamolo nella home del nostro debian user:

$ tar xvzf android-sdk_r07-linux_x86.tgz

3. Android Development Tools (ADT) Plugin per Eclipse

Eclipse dà la possibilità di inserire nell’IDE un URL attraverso il quale trovare ed installare i plugins. In particolare per installare l’ADT Plugin basta avviare l’IDE e selezionare dal menu:

Window → Preferences

Su questa finestra:

  • dalla lista a sinistra apriamo la sezione Install/Update
  • selezioniamo Available Software Sites
  • clicchiamo sul bottone Add a destra
  • inseriamo l’indirizzo dove reperire il plugin: https://dl-ssl.google.com/android/eclipse/
  • e infine clicchiamo su OK

Ora andiamo sul menu:

Help → Install New Software

Su questa finestra dal menu a tendina Work with: selezionate il repository appena inserito. Sotto scegliete Android Development Tools e proseguite nelle successive schermate (tra queste ci sarà anche l’accettazione della licenza).

A questo punto l’IDE chiede di essere riavviato. Dopo ciò, bisogna configurare il plugin in modo che sfrutti l’Android SDK installato al punto 2. Andiamo su:

Window → Preferences

Troveremo sulla lista a sinistra una nuova voce: Android. Selezioniamola e clicchiamo sul bottone Browse a destra inserendo la posizione dell’Android SDK del punto 2 (/home/stylee/android-sdk-linux_x86).

Se qualcosa dovesse andare storto, vi riporto il link alla guida esaustiva per l’installazione e configurazione del plugin.

4. Configurazione dell’Android SDK tramite il tool the Android SDK and AVD Manager

Il plugin è configurato all’interno dell’IDE. Ora dobbiamo configurare l’ambiente dell’ Android SDK per definire quale sarà il nostro dispositivo su cui svilupperemo l’applicazione. Il tool da utilizzare è lanciabile direttamente dall’interno di Eclipse con il bottone sul pannello pricipale:

Nel caso particolare, per produrre un package installabile sul mio Motorola FlipOut, dovrò installare le API 7 per Android v2.1 (menu Available Packages sulla sinistra):

Dopo le API bisogna creare un Android Virtual Device sul quale verrà testata la nostra app (tramite emulatore). Selezioniamo la voce Virtual Devices sulla sinistra. Il mio FlipOut ha 2Gb di scheda di memoria SD, Android 2.1 e risoluzione QVGA.

5. Hello Android

Creiamo un nuovo progetto con il wizard sulla barra principale di Eclipse:

Compilate i vari campi a vostro piacimento, seguendo le linee guida:

Aprite nell’editor la classe it.santasoft.helloandroid.HelloAndroid e modificate in questo modo:

package it.santasoft.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello JUGPadova! From my Android Device");
        setContentView(tv);
    }
}

Ora che abbiamo sistemato il codice, passiamo alla compilazione premendo il tasto sul pannello dell’IDE

Run → As Android Application

Verrà compilato il nostro package e lanciato l’emulatore definito precedentemente nella sezione Android Virtual Devices. Munitevi di pazienza e attendete qualche minuto che l’emulatore si avvii… e vedrete il risultato sperato.

Per maggiori informazioni e per alcuni approfondimenti sull’app HelloAndroid visitate questo link su developer.android.com

6. Installazione del package .apk sul dispositivo Android

Individuiamo il pacchetto Hello Android.apk all’interno dell’alberatura del nostro progetto compilato in Eclipse:

Hello Android → bin → it → Hello Android.apk

Sul nostro dispositivo Android andiamo ad installare dall’Android Market uno dei tanti Apps Installer che ci permettono di gestire pacchetti .apk all’interno della scheda di memoria SD esterna. Io utilizzo appInstaller di Gregory House.

Spegniamo il nostro dispositivo Android, estraiamo la scheda di memoria, inseriamola sul nostro PC e trasferiamo nella directory radice il package Hello android.apk; smontiamo la scheda, reinseriamo nel dispositivo e accendiamo.

Per questioni di sicurezza è disabilitata di default l’opzione di poter installare applicazioni al di fuori dell’Android Market, perciò per il nostro scopo navighiamo nel menu del nostro dispositivo e abilitiamo l’opzione

Impostazioni → Applicazioni → Origini Sconosciute

Avviamo l’applicazione appInstaller e scegliamo il nostro package Hello, Android. E finalmente otteniamo

Altro metodo molto veloce (testato di persona) se sul nostro Debian PC abbiamo installato il web server apache e siamo in una rete wifi domestica è il seguente.

  • Copiamo il nostro Hello Android.apk sulla root del webserver Apache – /var/www di default
  • Verifichiamo quale sia l’indirizzo IP del Debian PC connesso alla rete wifi domestica – supponiamo 192.168.2.51
  • Attiviamo il wifi sul dispositivo Android
  • Apriamo il browser del nostro smartphone all’indirizzo: http://192.168.2.51/Hello%20Android.apk
  • Dopo che il browser ha finito di scaricare il pacchetto comparirà una notifica: toccate la riga della notifica e vi verrà chiesto se volete installare il pacchetto.

(il %20 sostituisce lo spazio negli URL).

Posted in ,  | Tags , , ,  | 38 comments

Comments

  1. Avatar Lucio Benfante said about 19 hours later:

    Grazie, Dario, molto utile!

  2. Avatar Michele said 88 days later:

    Ottima guida. Aggiungo per completezza un altri 2 metodi. Visto che abbiamo l’SDK ed Eclipse. Invece di eseguire il RUN su un dispositivo virtuale si può eseguire direttamente sul proprio telefono. Basta collegarlo via USB ed abilitare la modalità Debug (Impostazioni -> Applicazioni -> Sviluppo -> Debug USB) In questo modo Eclipse installerà direttamente sul telefono l’applicazione (che rimane installata nel dispositivo) e la manderà in esecuzione. Stessa cosa può essere fatta a mano (Terminale – Riga di Comando). Ci si posiziona nella cartella Platform Tools dell’SDK (es. c:\Program Files\Android\android-sdk-windows\platform-tools) Qui c’è il comando adb.exe (Android Debug Bridge). Basta lanciare: adb install nomepacchetto.apk (se presente nella cartella, altrimenti il come del pacchetto con tutto il percorso) L’ADB installerà l’app nel device collegato via USB (sempre in modalità debug)

  3. Avatar fabio said 88 days later:

    cosa non funziona? Ho seguito alla lettera tutto e dopo aver installato eclipse , dal menu help -> install new software non si apre il form previsto e quindi sono impotente a preseguire , dov’è l’errore? ciao

  4. Avatar fabio said 91 days later:

    ho trovato … per qualche oscuro motivo erano cambiati i permessi delle cartelle … suggerisco a chi usa linux di verificare il proprietario dei pacchetti da installare prima di qualsiasi cosa bye

  5. Avatar Sebastiano said 102 days later:

    Ciao scusate l’ignoranza ma cosa rapprenta il package?

    it.santasoft.helloandroid

    contiene delle istruzioni o viene creato dal programma

  6. Avatar Dario said 137 days later:

    Il package è un meccanismo per organizzare le classi Java che scrivi, puoi sceglierlo a tuo piacimento.

  7. Avatar NFL Jerseys said 197 days later:

    Your website is so great that i love it very much. welcome to visit our http://www.nfls.cc to get more great products.

  8. Avatar Cheap Jerseys said 197 days later:

    Thank you for sharing your great website with us. i love it very much. welcome to visit our http://www.nfls.cc to get more great products.

  9. Avatar GHD Straigheners said 198 days later:

    That may be great that should be shady on the comprehensive practise due to a small number of damaging oatmeal? There is more than couple of valuable variance, they may be opinion. First of all, normally fears which usually knowledge actually works, no matter wrong and additionally fraudulent case will probably now and again come to be obtainable. Still when there is whatever “miraculous” permanent cures right from faith-healing, over the human body’s personally own power to fix its own matters, could be very a whole lot located at subject. Also, all the expose’ about rip-off and additionally corruption for knowledge created from basically purely just by knowledge. However, the key advertising mileage about rip-off and additionally corruption for faith-healing is almost do not conducted just by other sorts of faith-healers.

  10. Avatar Max said 221 days later:

    Thank for the information

  11. Avatar Cheap Nike Air Max said 235 days later:

    All around everyday living is definitely success. Luckily for us study will not be to get to unravel essential disputes. Everyday living on its own continue to remains to be an effective physical therapist. Your dog having your the key reason why to stay at might endure any kind of the best way. This can be the examine to seek out if a person’s mandate we know of is completed: when you are lively, doable. I actually develop in the am split amongst your aspire to help community including a aspire to have fun with the community. The following should make it very difficult so that you can system built. We do never feel dissapointed about a person moment in time with living.

  12. Avatar Cheap Tiffany Jewelry said 240 days later:

    Meant for mine piece We’d as soon get descended with the fact that heroic bit of monkey, what person braved this scary opposing just to save the for this keeper; or simply with the fact that ancient baboon, what person, descending within the mountain range, overly enthusiastic during triumph this adolescent comrade with a guests for astounded pups—mainly because with a savage what person delights that will torture this npcs, gives you away bloody forfeit, strategies infanticide not having remorse, appetizers this life partners for example slaves, is familiar with hardly any decency, as well as being haunted by way of the grossest superstitions.

  13. Avatar Ed Hardy Outlet said 248 days later:

    Concerning a super easy doctrine: Pack what on earth is clean. Clean what on earth is 100 %. Scrape when them itches. Everyone loves everyday living for the reason that just what exactly extra could there be. I actually continue to obtain day after day very shorter for your opinions I want to assume, many of the strolling I want to bring, many of the courses I want to learn, plus many of the associates I want to find.

  14. Avatar Ed Hardy Outlet said 254 days later:

    We have got find out numerous including editions involved with ideas within,and consequently my spouse and i was could thereby deposit any mainly blogcreators understand overall look on-line to be unhealthy,yet somehow joining your downline become vacationers, i love browse your amazing views,but soundest really feel completely happy and therefore may perhaps discover few things modern,in addition to the approach value your thoughts while

  15. Avatar Nike Lebron 8 said 256 days later:

    Regarding 30 in years past there is a lot speak which geologists should and then notice and never theorize; as well as We nicely keep in mind somebody stating which only at that price a guy may as well get into the gravel-pit as well as depend the actual small stones as well as explain the actual colors. Exactly how unusual it’s which anybody shouldn’t observe that just about all declaration should be with regard to or even towards a few look at if it’s to become associated with any kind of support!

  16. Avatar Tiffany & CO Outlet said 256 days later:

    Individuals possess killed one another, within substantial conflicts as well as guerilla measures, for a lot of hundreds of years, but still homicide one another in our, more than Ideologies as well as Beliefs that, mentioned because propositions, seem nor accurate neither fake in order to contemporary logicians—worthless propositions which appear significant towards the linguistically trusting.

  17. Avatar New Jordans 2011 said 261 days later:

    Freethinkers can be triggered willing to implement ones own opinions while not bias and even while not fearing to find out problems that battle utilizing possess persuits, rights, and certain principles. It mentality is simply not normal, though planning designed for best thinking about; at which it will be gone, topic is without a doubt prone to grown to be even more serious rather than crappy.

  18. Avatar Nike Air Force Ones Shoes said 270 days later:

    For a long time, the lethal turmoil may be waged in between several daring women and men associated with believed as well as guru on the main one aspect, and also the excellent uninformed spiritual bulk about the additional. This is actually the battle in between Technology as well as Belief. The actual couple of possess become a huge hit in order to cause, in order to recognition, in order to regulation, in order to independence, towards the recognized, and also to joy right here nowadays. The numerous possess become a huge hit in order to bias, in order to concern, in order to wonder, in order to captivity, towards the unfamiliar, and also to agony hereafter. The actual couple of possess stated “Think” The numerous possess stated “Believe! inch

  19. Avatar New Air Max 2011 said 276 days later:

    Just what effect, in reality, have got ecclesiastical organizations acquired about community? Occasionally they are noticed to be able to put up any non secular tyranny around the wrecks with the city specialist; about several circumstances they are noticed upholding the particular thrones regarding political tyranny; inside simply no illustration have got they will recently been the particular adults with the liberties with the folks. Rulers who want to subvert people liberty could have identified an existing clergy hassle-free auxiliaries. Any merely authorities, instituted to be able to protected and also perpetuate that, wants these not necessarily.

  20. Avatar Custom essays said 339 days later:

    What a great content! Thanks a lot for your article!!

  21. Avatar BestKevin said 345 days later:

    Ottimo !!! :) Grazie :) Ora vedo di andare un po’ oltre :) ma questa guida va bene :) Nota: non mettere il wget, e’ comodo ma “scade” con gli aggiornamenti…meglio mettere il link a google dove andare a scaricare la versione attuale: http://developer.android.com/sdk/index.html

    Grazie ancora.

  22. Avatar PARSONS20Alma said 365 days later:

    If you are willing to buy a car, you would have to receive the business loans. Furthermore, my mother commonly utilizes a credit loan, which is really useful.

  23. Avatar HUNTHEATHER said 371 days later:

    Do you acknowledge that it is the best time to get the business loans, which would realize your dreams.

  24. Avatar HENDRICKSVilma23 said 898 days later:

    Frankly speaking, it is very tough to write first-rate essays without opting for paper writing service. Each student realizes that composing of any type of college writing demands much time, therefore, grads prefer to buy essay writing service.

  25. Avatar Talley32Marguerite said 948 days later:

    Visit home page if you would like to acquire papers service uk.

  26. Avatar Gretchen31Chandler said 1011 days later:

    A short time ago, students are very busy to produce papers, they may click here, and purchase college research paper. Turning to this superb paper writing firm sophomores will get assignment writing services.

  27. Avatar Fisher28Suzette said 1015 days later:

    Buy essay writing services if you aren’t positive about your composition skills and desire professional academic writer to create essays for you. Mercifully, there are lots of bureaus which will be happy to provide their essay services to undegrads who want to find pre-written essays.

  28. Avatar EPC electrical contractor said 1088 days later:

    I loved the article. It is very exciting. Thank you for the information. I will be back.

  29. Avatar Turnkey Solution providers said 1088 days later:

    Thanks you for the information provided. The best content I’ve seen on this topic

  30. Avatar <a href="http://www.superwatchus.com" target="_blank">Superwatchus</a> said 1103 days later:

    Wow this is a great post. This contain have many useful information. Please post more information to share with us.

  31. Avatar Superwatchus said 1103 days later:

    Thanks for the writeup. I definitely agree with what you are saying. I have been talking about this subject a lot lately with my brother so hopefully this will get him to see my point of view. Fingers crossed!

  32. Avatar LENABass33 said 1135 days later:

    Desire to buy uk papers of excellent quality? Check out Internet site!

  33. Avatar LUZWhitney35 said 1137 days later:

    Do you get what college guys seem to be aimed at? They guys are concentrated on the best results! However, to receive supreme quality academic papers you need to have someone like custom research paper writing company to aid you.

  34. Avatar how to buy soundcloud plays said 1430 days later:

    Thanks for the share. I really appreciate it. This tutorial seems to be very helpful for us. Thanks

  35. Avatar LynSbo said 1512 days later:

    This web site is really a walk-through for all of the info you wanted about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it….

  36. Avatar Google said 1726 days later:

    Great site

  37. Avatar www.ukwatchjust.org.uk said 1826 days later:

    Consider the admeasurement of the getting you are purchasing the watch for. Abounding watch bands can be adapted for a absolute fit.

  38. Avatar www.watchuk.org.uk said 1826 days later:

    The absolute could cause of this comes about because a lot of humans anyhow buy added you watch every time they appear online!

(leave url/email »)

   Comment Markup Help Preview comment