Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati
  • Differenze per "Programmazione/AndroidSdk"
Differenze tra le versioni 1 e 21 (in 20 versioni)
Versione 1 del 09/09/2011 01.40.58
Dimensione: 9408
Autore: NaldiniPaolo
Commento: Pagina creata e da tradurre
Versione 21 del 10/09/2011 09.01.09
Dimensione: 15086
Commento:
Le cancellazioni sono segnalate in questo modo. Le aggiunte sono segnalate in questo modo.
Linea 4: Linea 4:
This is a general overview of what the Android SDK is, what it does, and how it can benefit you. This guide also contains instructions on how to set up the Android SDK on Ubuntu 10.04 onwards.
Linea 6: Linea 5:
= Introduction =
||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<BR>><<TableOfContents(2)>>||
<<BR>>
<<Indice>>
<<Informazioni(forum="http://forum.ubuntu-it.org/index.php/topic,479313.0.html"; rilasci="11.04")>>
Linea 9: Linea 9:
The Android Software Development Kit (AKA SDK) is a software suite for the Android mobile operating system that allows you to write applications for Android in the Java programming language. Most people who use the Android SDK either develop applications for the Android operating system OR they use it for other purposes, such as obtaining elevated privileges on an Android device with the help of third-party software or use it for diagnostic purposes in case of malfunctioning.
Linea 11: Linea 10:
The vast majority of Android users probably won't have to make use of the Android SDK, however, it is useful if you wish to learn more about the Android operating system and even then it's still a handy tool to have in case something goes wrong. = Introduzione =
Linea 13: Linea 12:
This tutorial covers Ubuntu 10.04 Lucid Lynx onwards. For anything prior to Lucid, you will have to find it yourself. In questa guida verrà presentato in linea generale '''Android SDK''' e le sue principali funzionalità. Inoltre verranno riportate le istruzioni su come installare e configurare Andorid SDK sul sistema operativo Ubuntu.
Linea 15: Linea 14:
= Preparation and Installation = ##This is a general overview of what the Android SDK is, what it does, and how it can benefit you. This guide also contains instructions on how to set up the Android SDK on Ubuntu 10.04 onwards.
Linea 17: Linea 16:
Before we set up the SDK, we have some preparation to do. Due to some major changes in the Android SDK made in the last couple of months, setting up the Android SDK is not as easy as it was two years ago, when Android was starting to take off. Setting up the SDK itself is relatively easy once the preparation has been done. = Che cos'è Android SDK =
Linea 19: Linea 18:
== Downloading the SDK Starter Package == Android '''S'''oftware '''D'''evelopment '''K'''it (SDK) è un insieme di strumenti legato al sistema operativo Android che permette di scrivere e sviluppare applicazioni nel linguaggio di programmazione [[Programmazione/Java|Java]]. Oltre che per lo sviluppo di applicazioni, Andorid SDK è utilizzato, per esempio, per ottenere i privilegi di amministratore su un dispositivo Android con l'aiuto di applicazioni di terze parti oppure per cercare e risolvere problemi in caso di malfunzionamento.
Linea 21: Linea 20:
First things first, we have to obtain the starter package. The SDK starter package can be obtained at http://developer.android.com/sdk/index.html. La maggior parte degli utenti che utilizzano Android non si preoccupa di utilizzare questo strumento, tuttavia diventa molto utile nel caso in cui si voglia conoscere meglio il sistema operativo e soprattutto nel caso in cui qualcosa vada storto.
Linea 23: Linea 22:
Download the one for Linux (.tgz file) and once it's finished downloading, extract it to somewhere safe and easy to reach. For example, the home folder. To do so, open up a terminal, navigate to the directory where the SDK was downloaded and enter the following command: ##The Android Software Development Kit (AKA SDK) is a software suite for the Android mobile operating system that allows you to write applications for Android in the Java programming language. Most people who use the Android SDK either develop applications for the Android operating system OR they use it for other purposes, such as obtaining elevated privileges on an Android device with the help of third-party software or use it for diagnostic purposes in case of malfunctioning.
Linea 25: Linea 24:
||$ tar -xvzf android-sdk_rXX-linux_x86.tgz && mv android-sdk-linux_x86 /home/USER || ##The vast majority of Android users probably won't have to make use of the Android SDK, however, it is useful if you wish to learn more about the Android operating system and even then it's still a handy tool to have in case something goes wrong.
Linea 27: Linea 26:
As of 6 September 2011, the Android SDK is currently up to r12, however that is set to change in the near future, and as such, replace XX with the version of your SDK. Be sure to replace USER with your username. = Preparazione e installazione =
Linea 29: Linea 28:
== Setting up Java == Prima di iniziare a configurare SDK è necessario preparare il nostro sistema in modo da procedere correttamente con l'installazione. L'installazione di SDK non è così immediata rispetto a come lo era due anni fa in seguito a importanti aggiornamenti che sono stati effettuati durante questo periodo. La configurazione di SDK invece è relativamente semplice.
Linea 31: Linea 30:
Prior to SDK r08, everything you'll need to develop applications was included on a 100-200MB .tgz archive. However, with the release of SDK r08, the tools necessary for creating and building applications was removed and can be obtained by using the Android SDK and AVD Manager which is located in the /<sdk>/tools folder. ##Before we set up the SDK, we have some preparation to do. Due to some major changes in the Android SDK made in the last couple of months, setting up the Android SDK is not as easy as it was two years ago, when Android was starting to take off. Setting up the SDK itself is relatively easy once the preparation has been done.
Linea 33: Linea 32:
However, you should not execute the Android SDK and AVD manager just yet, as you'll most likely get a Parse: XML error notice. The reason for this is that after SDK r08, it's now required to have Java installed before you set up the SDK. To do this, we'll download the OpenJDK and the Icedtea browser plugin. In a terminal window, enter the following command: == Scaricare il pacchetto Android SDK ==
Linea 35: Linea 34:
||$ sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin|| Scaricare ed [[http://wiki.ubuntu-it.org/AmministrazioneSistema/FormatiDiCompressione|estrarre]] il pacchetto `.tar.gz`, relativo alla versione Linux, reperibile da [[http://developer.android.com/sdk/index.html|questa pagina]].
Linea 37: Linea 36:
This will download and install the OpenJDK implementation of Java, which will be sufficient enough for us to download the SDK platform tools. ##First things first, we have to obtain the starter package. The SDK starter package can be obtained at http://developer.android.com/sdk/index.html.
Linea 39: Linea 38:
== Downloading the SDK platform tools == ##Download the one for Linux (.tgz file) and once it's finished downloading, extract it to somewhere safe and easy to reach. For example, the home folder. To do so, open up a terminal, navigate to the directory where the SDK was downloaded and enter the following command:
Linea 41: Linea 40:
This is pretty much the actual "installation" of the SDK's platform tools. One key reason why this step is important is that it contains an important protocol called the Android Debug Bridge (ADB). ##||$ tar -xvzf android-sdk_rXX-linux_x86.tgz && mv android-sdk-linux_x86 /home/USER ||
Linea 43: Linea 42:
ADB comes bundled with the SDK platform tools. It is a command-line tool used to communicate with and control the device over a USB link from a computer. The tool comes bundled with the Android SDK and is commonly used for diagnosing problems with the device. Once you have ADB installed, you can use ADB to copy files to and from the device's internal memory, install apps, run commands, see logs and more. This makes it an invaluable tool if your device is running into some trouble that might warrant a new device. ##As of 6 September 2011, the Android SDK is currently up to r12, however that is set to change in the near future, and as such, replace XX with the version of your SDK. Be sure to replace USER with your username.
Linea 45: Linea 44:
Now, in order to obtain the SDK platform tools, we'll need to initialize the Android SDK and AVD Manager that I mentioned earlier. To do so, enter the following commands in a terminal. The first command will direct you to where the Android SDK and AVD Manager is located, and the second will execute said program. == Configurare Java ==
Linea 47: Linea 46:
|| $ cd ~/android-sdk-linux_x86/tools||
|| $ ./android ||
Fino alla versione r07 di SDK tutto quello che era necessario per lo sviluppo di applicazioni era incluso in un unico archivio `.tgz`. Tuttavia, con il rilascio della versione r08, tutti gli strumenti necessari si possono ottenere utilizzando '''AVD Manager''' posizionato nella cartella ''/<sdk>/tools''.
Linea 50: Linea 48:
Once you do that, a new window will pop up, which is the actual Android SDK and AVD Manager. Click on "Available Packages" and you will be presented with two boxes. One is the Android Repository and the other is the Third-party Add-ons. Click on "Android Repository" then click on Install Selected. A confirmation window will pop up. Click on "Accept All" and then click on the Install button to install the SDK platform tools. It's quite a bit to download so make sure you have at least 512MB to 2GB of hard drive space available. Once the download has finished, you'll get a notice saying that the ADB daemon needs to be restarted. Click on "Yes" and everything will finish downloading. Prima di poter avviare AVD Manager è necessario però configurare '''Java''' in modo da non ricevere nessun errore XML. Per fare questo [[AmministrazioneSistema/InstallareProgrammi|installare]] i seguenti pacchetti:
Linea 52: Linea 50:
= Post-Installation Configuration =  * [[apt://openjdk-6-jre|openjdk-6-jre]]
Linea 54: Linea 52:
Now once the download has finished, or while you're waiting for the download to finish, we have to configure Ubuntu a little to meet our needs. First, we have to set up the PATH variable to include ADB and other SDK tools, and we have to make sure our hardware will be detected once we initialize ADB.  * [[apt://openjdk-6-jdk|openjdk-6-jdk]]
Linea 56: Linea 54:
== Modifying the PATH Environment Variable ==  * [[apt://icedtea6-plugin|icedtea6-plugin]]
Linea 58: Linea 56:
In the days before Android 2.2, a good number of people used to place their various projects and applications in the directories where the necessary tools they used existed. This was in itself a very flawed method because it cluttered up the directories, and while cleaning up the SDK, one might accidentally delete a crucial file, which will cause the SDK to fail and having to completely reinstall everything. In questo modo verrà installato '''OpenJDK''', un'implementazione di Java che permetterà l'utilizzo corretto della piattaforma SDK.
Linea 60: Linea 58:
Modifying the PATH Environment Variable will help out immensely when it comes down to making use of SDK tools like ADB. Doing this will also allow you to execute certain protocols like ADB from ANY location. So if you're operating from the Desktop, you don't have to redirect to the SDK's platform-tools folder to make use of ADB if you need to make use of it. ##Prior to SDK r08, everything you'll need to develop applications was included on a 100-200MB .tgz archive. However, with the release of SDK r08, the tools necessary for creating and building applications was removed and can be obtained by using the Android SDK and AVD Manager which is located in the /<sdk>/tools folder.
Linea 62: Linea 60:
Enough chatter, let's get busy. To modify the PATH variable of your system, you need to edit your .bashrc file. To do so, in a terminal, execute the following command: ##However, you should not execute the Android SDK and AVD manager just yet, as you'll most likely get a Parse: XML error notice. The reason for this is that after SDK r08, it's now required to have Java installed before you set up the SDK. To do this, we'll download the OpenJDK and the Icedtea browser plugin. In a terminal window, enter the following command:
Linea 64: Linea 62:
|| $ nano ~/.bashrc || ##||$ sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin||
Linea 66: Linea 64:
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following: ##This will download and install the OpenJDK implementation of Java, which will be sufficient enough for us to download the SDK platform tools.
Linea 68: Linea 66:
|| #AndroidDev PATH ||
|| export PATH=${PATH}:~/android-sdk-linux_x86/tools ||
|| export PATH=${PATH}:~/android-sdk-linux_x86/platform-tools ||
== Scaricare gli strumenti per SDK ==
Linea 72: Linea 68:
Once you're finished, press CTRL + X, Y, and then hit Enter to save your changes and exit the Nano text editor. Android SDK contiene un importante protocollo chiamato '''A'''ndroid '''D'''ebug '''B'''ridge (ADB).
Linea 74: Linea 70:
== Preparing Hardware == ADB è contenuto nell'installazione della piattaforma SDK. Esso è uno strumento utilizzabile da linea di comando, utilizzato per controllare e comunicare con dispositivi collegati con cavo USB. Una volta installato, è possibile utilizzare ADB per copiare e trasferire file dal computer al dispositivo mobile, installare applicazioni, lanciare comandi, visualizzare file di log e molto altro.
Linea 76: Linea 72:
Now that we have our PATH variable set up, we need to make sure our hardware will be detected once we initialize ADB. However, Ubuntu won't allow ADB access to the Android phone via USB unless the appropriate udev rule is set. This is Bug #316215. In order to provide such rule, you need to create a rule file as root. Per ottenere questi strumenti è necessario eseguire Android SDK e AVD Manager, spostarsi quindi nella cartella `~/android-sdk-linux_x86/tools` e digitare in un terminale il seguente comando:
Linea 78: Linea 74:
In a terminal, execute the following command that will create the rule file. This will utilize the graphical sudo command, so that we can still have control over the file if we're not a root user. {{{
./android
}}}
Linea 80: Linea 78:
|| $ gksudo gedit /etc/udev/rules.d/51-android.rules || Nella nuova finestra che comparirà, fare clic sulla voce '''Available Packages'''. Saranno quindi disponibili il repository ufficiale di Android e quello di terze parti, in questo caso fare clic su '''Android Repository''' e installare il repository selezionato. Fare ora clic sulla voce '''Accept All''' e procedere con l'installazione.
Linea 82: Linea 80:
Copy and paste the following udev rules in the text editor that opened up which contains the new rule file we created. The rules included should work with most if not all Android devices across multiple manufacturers, such as HTC, Motorola, LGE, and so forth. ||<tablestyle="text-align: justify; width:100%;" style="border:none;" 5%><<Immagine(Icone/Piccole/warning.png,,center)>> ||<style="padding:0.5em; border:none;">'''Controllare di avere a disposizione almeno 2 GB di memoria libera nell'hard disk.''' ||
Linea 84: Linea 82:
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666" ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666" ||
|| SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″ ||
|| SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev ||
Una volta conclusa la fase di download si verrà informati che il demone ADB sarà riavviato. Fare clic su '''Yes''' per terminare.
Linea 95: Linea 84:
Once you've copied and pasted the udev rules in the text editor which contains your newly created rule file, save your changes and quit. Now that you've set your udev rules you have to reboot so that ADB will be in your path. ##This is pretty much the actual "installation" of the SDK's platform tools. One key reason why this step is important is that it contains an important protocol called the Android Debug Bridge (ADB).
Linea 97: Linea 86:
To test your changes, open up a terminal and execute the following: ##ADB comes bundled with the SDK platform tools. It is a command-line tool used to communicate with and control the device over a USB link from a computer. The tool comes bundled with the Android SDK and is commonly used for diagnosing problems with the device. Once you have ADB installed, you can use ADB to copy files to and from the device's internal memory, install apps, run commands, see logs and more. This makes it an invaluable tool if your device is running into some trouble that might warrant a new device.
Linea 99: Linea 88:
|| $ adb devices || ##Now, in order to obtain the SDK platform tools, we'll need to initialize the Android SDK and AVD Manager that I mentioned earlier. To do so, enter the following commands in a terminal. The first command will direct you to where the Android SDK and AVD Manager is located, and the second will execute said program.
Linea 101: Linea 90:
This will give you two messages: ##|| $ cd ~/android-sdk-linux_x86/tools||
##|| $ ./android ||
Linea 103: Linea 93:
1) It will tell you it's initializing the ADB daemon.
2) It should show you a list of connected devices.
##Once you do that, a new window will pop up, which is the actual Android SDK and AVD Manager. Click on "Available Packages" and you will be presented with two boxes. One is the Android Repository and the other is the Third-party Add-ons. Click on "Android Repository" then click on Install Selected. A confirmation window will pop up. Click on "Accept All" and then click on the Install button to install the SDK platform tools. It's quite a bit to download so make sure you have at least 512MB to 2GB of hard drive space available. Once the download has finished, you'll get a notice saying that the ADB daemon needs to be restarted. Click on "Yes" and everything will finish downloading.
Linea 106: Linea 95:
If all went well you should see your device's serial number under the list of connected devices. If you see a message like: = Configurazione del sistema =
Linea 108: Linea 97:
|| List of connected devices ||
|| ???????? No permissions ||
Per un corretto funzionamento di SDK è necessario effettuare qualche modifica a Ubuntu. Prima di tutto bisogna impostare il percorso che andrà a include ADB e gli altri strumenti di SDK, successivamente controllare che il proprio hardware verrà riconosciuto una volta lanciato ADB.
Linea 111: Linea 99:
This means your hardware was detected, however you made a mistake in configuring Ubuntu or the udev rule for your phone's manufacturer was not listed. ##Now once the download has finished, or while you're waiting for the download to finish, we have to configure Ubuntu a little to meet our needs. First, we have to set up the PATH variable to include ADB and other SDK tools, and we have to make sure our hardware will be detected once we initialize ADB.

== Modificare il percorso per l'ambiente SDK ==

Un buon numero di utenti era solito posizionare i propri progetti e applicazioni nelle stesse directory dove erano presenti gli strumenti necessari. Ciò era altamente rischioso poiché le directory vengono ingombrate e, in seguito ad una pulizia a SDK, era possibile che un file importante venisse cancellato causando l'arresto immediato del programma. La modifica di questo percorso aiuterà l'utente a utilizzare in modo sicuro strumenti come ADB e permetterà di avviarlo da qualsiasi directory ci si trovi.

Modificare con un [[Ufficio/EditorDiTesto|editor di testo]] il file `.bashrc` presente nella propria home e inserire all'inizio del file le seguenti linee di testo:

{{{
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux_x86/tools
export PATH=${PATH}:~/android-sdk-linux_x86/platform-tools

}}}

##In the days before Android 2.2, a good number of people used to place their various projects and applications in the directories where the necessary tools they used existed. This was in itself a very flawed method because it cluttered up the directories, and while cleaning up the SDK, one might accidentally delete a crucial file, which will cause the SDK to fail and having to completely reinstall everything.

##Modifying the PATH Environment Variable will help out immensely when it comes down to making use of SDK tools like ADB. Doing this will also allow you to execute certain protocols like ADB from ANY location. So if you're operating from the Desktop, you don't have to redirect to the SDK's platform-tools folder to make use of ADB if you need to make use of it.

##Enough chatter, let's get busy. To modify the PATH variable of your system, you need to edit your .bashrc file. To do so, in a terminal, execute the following command:

##|| $ nano ~/.bashrc ||

##You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:

##|| #AndroidDev PATH ||
##|| export PATH=${PATH}:~/android-sdk-linux_x86/tools ||
##|| export PATH=${PATH}:~/android-sdk-linux_x86/platform-tools ||

##Once you're finished, press CTRL + X, Y, and then hit Enter to save your changes and exit the Nano text editor.

== Preparazione dell'hardware ==

Per controllare se il proprio dispositivo viene riconosciuto da ADB, aprire una finestra di terminale e digitare il seguente comando:
{{{
adb devices
}}}

Comparirà in elenco il dispositivo collegato tramite cavo USB.

||<tablestyle="text-align: justify; width:100%;" style="border:none;" 5%><<Immagine(Icone/Piccole/note.png,,center)>> ||<style="padding:0.5em; border:none;">''Se il dispositivo non viene visualizzato correttamente fare riferimento al seguente [[https://bugs.launchpad.net/ubuntu/+source/udev/+bug/316215|bug (#316215)]]''. ||


##Now that we have our PATH variable set up, we need to make sure our hardware will be detected once we initialize ADB. However, Ubuntu won't allow ADB access to the Android phone via USB unless the appropriate udev rule is set. This is Bug #316215. In order to provide such rule, you need to create a rule file as root.

##In a terminal, execute the following command that will create the rule file. This will utilize the graphical sudo command, so that we can still have control over the file if we're not a root user.

##|| $ gksudo gedit /etc/udev/rules.d/51-android.rules ||

##Copy and paste the following udev rules in the text editor that opened up which contains the new rule file we created. The rules included should work with most if not all Android devices across multiple manufacturers, such as HTC, Motorola, LGE, and so forth.

##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666" ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666" ||
##|| SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″ ||
##|| SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev ||

##Once you've copied and pasted the udev rules in the text editor which contains your newly created rule file, save your changes and quit. Now that you've set your udev rules you have to reboot so that ADB will be in your path.

##To test your changes, open up a terminal and execute the following:

##|| $ adb devices ||

##This will give you two messages:

##1) It will tell you it's initializing the ADB daemon.
##2) It should show you a list of connected devices.

##If all went well you should see your device's serial number under the list of connected devices. If you see a message like:

##|| List of connected devices ||
##|| ???????? No permissions ||

##This means your hardware was detected, however you made a mistake in configuring Ubuntu or the udev rule for your phone's manufacturer was not listed.

= Ulteriori risorse =

 * [[https://help.ubuntu.com/community/AndroidSDK|Documento originale]]
 * [[http://developer.android.com/sdk/index.html|Pagina ufficiale di Android SDK]]

Linea 113: Linea 186:
CategoryDaTradurre CategoryNuoviDocumenti


Problemi in questa pagina? Segnalali in questa discussione

Introduzione

In questa guida verrà presentato in linea generale Android SDK e le sue principali funzionalità. Inoltre verranno riportate le istruzioni su come installare e configurare Andorid SDK sul sistema operativo Ubuntu.

Che cos'è Android SDK

Android Software Development Kit (SDK) è un insieme di strumenti legato al sistema operativo Android che permette di scrivere e sviluppare applicazioni nel linguaggio di programmazione Java. Oltre che per lo sviluppo di applicazioni, Andorid SDK è utilizzato, per esempio, per ottenere i privilegi di amministratore su un dispositivo Android con l'aiuto di applicazioni di terze parti oppure per cercare e risolvere problemi in caso di malfunzionamento.

La maggior parte degli utenti che utilizzano Android non si preoccupa di utilizzare questo strumento, tuttavia diventa molto utile nel caso in cui si voglia conoscere meglio il sistema operativo e soprattutto nel caso in cui qualcosa vada storto.

Preparazione e installazione

Prima di iniziare a configurare SDK è necessario preparare il nostro sistema in modo da procedere correttamente con l'installazione. L'installazione di SDK non è così immediata rispetto a come lo era due anni fa in seguito a importanti aggiornamenti che sono stati effettuati durante questo periodo. La configurazione di SDK invece è relativamente semplice.

Scaricare il pacchetto Android SDK

Scaricare ed estrarre il pacchetto .tar.gz, relativo alla versione Linux, reperibile da questa pagina.

Configurare Java

Fino alla versione r07 di SDK tutto quello che era necessario per lo sviluppo di applicazioni era incluso in un unico archivio .tgz. Tuttavia, con il rilascio della versione r08, tutti gli strumenti necessari si possono ottenere utilizzando AVD Manager posizionato nella cartella /<sdk>/tools.

Prima di poter avviare AVD Manager è necessario però configurare Java in modo da non ricevere nessun errore XML. Per fare questo installare i seguenti pacchetti:

In questo modo verrà installato OpenJDK, un'implementazione di Java che permetterà l'utilizzo corretto della piattaforma SDK.

Scaricare gli strumenti per SDK

Android SDK contiene un importante protocollo chiamato Android Debug Bridge (ADB).

ADB è contenuto nell'installazione della piattaforma SDK. Esso è uno strumento utilizzabile da linea di comando, utilizzato per controllare e comunicare con dispositivi collegati con cavo USB. Una volta installato, è possibile utilizzare ADB per copiare e trasferire file dal computer al dispositivo mobile, installare applicazioni, lanciare comandi, visualizzare file di log e molto altro.

Per ottenere questi strumenti è necessario eseguire Android SDK e AVD Manager, spostarsi quindi nella cartella ~/android-sdk-linux_x86/tools e digitare in un terminale il seguente comando:

./android

Nella nuova finestra che comparirà, fare clic sulla voce Available Packages. Saranno quindi disponibili il repository ufficiale di Android e quello di terze parti, in questo caso fare clic su Android Repository e installare il repository selezionato. Fare ora clic sulla voce Accept All e procedere con l'installazione.

Controllare di avere a disposizione almeno 2 GB di memoria libera nell'hard disk.

Una volta conclusa la fase di download si verrà informati che il demone ADB sarà riavviato. Fare clic su Yes per terminare.

Configurazione del sistema

Per un corretto funzionamento di SDK è necessario effettuare qualche modifica a Ubuntu. Prima di tutto bisogna impostare il percorso che andrà a include ADB e gli altri strumenti di SDK, successivamente controllare che il proprio hardware verrà riconosciuto una volta lanciato ADB.

Modificare il percorso per l'ambiente SDK

Un buon numero di utenti era solito posizionare i propri progetti e applicazioni nelle stesse directory dove erano presenti gli strumenti necessari. Ciò era altamente rischioso poiché le directory vengono ingombrate e, in seguito ad una pulizia a SDK, era possibile che un file importante venisse cancellato causando l'arresto immediato del programma. La modifica di questo percorso aiuterà l'utente a utilizzare in modo sicuro strumenti come ADB e permetterà di avviarlo da qualsiasi directory ci si trovi.

Modificare con un editor di testo il file .bashrc presente nella propria home e inserire all'inizio del file le seguenti linee di testo:

#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux_x86/tools
export PATH=${PATH}:~/android-sdk-linux_x86/platform-tools

Preparazione dell'hardware

Per controllare se il proprio dispositivo viene riconosciuto da ADB, aprire una finestra di terminale e digitare il seguente comando:

adb devices

Comparirà in elenco il dispositivo collegato tramite cavo USB.

Se il dispositivo non viene visualizzato correttamente fare riferimento al seguente bug (#316215).

Ulteriori risorse


CategoryNuoviDocumenti