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 6 e 7
Versione 6 del 09/09/2011 09.32.55
Dimensione: 11543
Autore: NaldiniPaolo
Commento: Tradotto ancora qualcosa
Versione 7 del 09/09/2011 09.33.47
Dimensione: 11543
Autore: NaldiniPaolo
Commento:
Le cancellazioni sono segnalate in questo modo. Le aggiunte sono segnalate in questo modo.
Linea 16: Linea 16:
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 applicazione di terze parti oppure per cercare e risolvere problemi in caso di malfunzionamento. 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.


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 su Ubuntu 10.04 e successive.

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 Android non ha a che fare con questo strumento, tuttavia è molto utile nel caso in cui si voglia conoscere meglio il sistema operativo e soprattutto se qualcosa va 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.

Downloading the SDK platform tools

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).

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.

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.

$ cd ~/android-sdk-linux_x86/tools

$ ./android

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.

Post-Installation Configuration

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.

Modifying the PATH Environment Variable

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.

Preparing Hardware

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.


CategoryDaTradurre