lunedì 2 settembre 2013

Setup Qt5 per Android

Finalmente dopo un po' di tentativi non riusciti con la versione 5.1, ho compilato un programma per Android realizzato mediante le Qt 5.1.1

Attenzione: per la mia esperienza e' decisamente meglio utilizzare le Qt 5.1.1 su Linux piuttosto che in Windows...non so bene il motivo ma in XP il compilatore e' decisamente lento e non trova mai la fine
Attenzione 2 : la compilazione e l'esecuzione ha avuto successo solo un dispositivo reale (Nexus S) in quanto l'emulatore Android non viene agganciato da QtCreator e non viene copiato l'apk (errore Starting remote process. Unable to start 'org.qtproject.t1')
Attenzione 3: questa riga dovrebbe andare al termine ma e' bene metterla in evidenzia. Il solo programma Hello World occupa 30.26 Mb !!!!


Una volta scaricato ed installato il pacchetto Qt 5.1.1 for Android (Linux 32-bit, 461 MB) si deve procedere a configurare l'ambiente QtCreator per indicare dove sono ubicate le directory dell'SDK e dell'NDK di Android. La cosa migliore e' ovviamente avere l'ultima versione aggiornata che nel mio caso e' l'NDK 9. Devono inoltre essere installati Ant e deve essere indicata la directory della Java VM


All'avvio di QtCreator (versione Linux) compare il seguente errore. La libreria libgstreamer-0.10.so e' presente. L'errore non pregiudica la compilazione ed esecuzione dei programmi



Una volta creato un progetto Android di base (il semplice Hello World) si puo' lanciare l'esecuzione usando come target Android for arm
Vengono generati i seguenti messaggi
----------------------------------------------
11:55:58: Running steps for project t1...
11:55:58: Configuration unchanged, skipping qmake step.
11:55:58: Starting: "/usr/bin/make" 
make: Nothing to be done for `first'.
11:55:58: The process "/usr/bin/make" exited normally.
11:55:58: Starting: "/usr/bin/make" INSTALL_ROOT=/home/luca/qt5_dir/t1/android install
cp -f -R /home/luca/qt5_dir/t1/qml/t1 /home/luca/qt5_dir/t1/android/assets/qml/
install -m 755 -p "libt1.so" "/home/luca/qt5_dir/t1/android/libs/armeabi-v7a/libt1.so"
11:55:58: The process "/usr/bin/make" exited normally.
11:55:58: Copy Qt app & libs to Android package ...
11:56:00: Creating package file ...
11:56:00: Package deploy: Running command '/usr/bin/ant clean debug'.
Buildfile: /home/luca/qt5_dir/t1/android/build.xml

-check-env:
 [checkenv] Android SDK Tools Revision 22.0.5
 [checkenv] Installed at /home/luca/android/sdk

-setup:
     [echo] Project Name: T1
  [gettype] Project Type: Application

-pre-clean:

clean:
[getlibpath] Library dependencies:
[getlibpath] No Libraries
   [subant] No sub-builds to iterate on

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 22.0.5
 [checkenv] Installed at /home/luca/android/sdk

-setup:
     [echo] Project Name: T1
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 18.0.1
     [echo] Resolving Build Target for T1...
[gettarget] Project Target:   Android 2.3.3
[gettarget] API level:        10
[gettarget] WARNING: No minSdkVersion value set. Application will install on all Android versions.
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/luca/qt5_dir/t1/android/bin
    [mkdir] Created dir: /home/luca/qt5_dir/t1/android/bin/res
    [mkdir] Created dir: /home/luca/qt5_dir/t1/android/gen
    [mkdir] Created dir: /home/luca/qt5_dir/t1/android/bin/classes
    [mkdir] Created dir: /home/luca/qt5_dir/t1/android/bin/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for T1...
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] Found 2 AIDL files.
     [aidl] Compiling 2 AIDL files.
     [echo] ----------
     [echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 6 source files to /home/luca/qt5_dir/t1/android/bin/classes

-post-compile:

-obfuscate:

-dex:
      [dex] input: /home/luca/qt5_dir/t1/android/bin/classes
      [dex] input: /home/luca/android/sdk/tools/support/annotations.jar
      [dex] input: /home/luca/qt5_dir/t1/android/libs/--Managed_by_Qt_Creator--QtAndroid-bundled.jar
      [dex] Pre-Dexing /home/luca/android/sdk/tools/support/annotations.jar -> annotations-d989d2aabb78bbfbe6fcbd2162e157ce.jar
      [dex] Pre-Dexing /home/luca/qt5_dir/t1/android/libs/--Managed_by_Qt_Creator--QtAndroid-bundled.jar -> --Managed_by_Qt_Creator--QtAndroid-bundled-11a7e4dd2e664969be723f2377cf863f.jar
      [dex] Converting compiled files and external libraries into /home/luca/qt5_dir/t1/android/bin/classes.dex...
       [dx] Merged dex A (23 defs/37,5KiB) with dex B (2 defs/1,1KiB). Result is 25 defs/44,8KiB. Took 0,2s
       [dx] Merged dex A (25 defs/44,8KiB) with dex B (27 defs/40,3KiB). Result is 52 defs/101,4KiB. Took 0,1s

-crunch:
   [crunch] Crunching PNG Files in source dir: /home/luca/qt5_dir/t1/android/res
   [crunch] To destination dir: /home/luca/qt5_dir/t1/android/bin/res
   [crunch] Crunched 0 PNG files to update cache

-package-resources:
     [aapt] Creating full resource package...

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating T1-debug-unaligned.apk and signing it with a debug key...

-post-package:

-do-debug:
 [zipalign] Running zip align on final apk...
     [echo] Debug Package: /home/luca/qt5_dir/t1/android/bin/T1-debug.apk
[propertyfile] Creating new property file: /home/luca/qt5_dir/t1/android/bin/build.prop
[propertyfile] Updating property file: /home/luca/qt5_dir/t1/android/bin/build.prop
[propertyfile] Updating property file: /home/luca/qt5_dir/t1/android/bin/build.prop
[propertyfile] Updating property file: /home/luca/qt5_dir/t1/android/bin/build.prop

-post-build:

debug:

BUILD SUCCESSFUL
Total time: 20 seconds
11:56:21: Package created.
11:56:21: Installing package onto 373342FC9C0400EC.
11:56:21: Package deploy: Running command '/home/luca/android/sdk/platform-tools/adb -s 373342FC9C0400EC uninstall org.qtproject.example.t1'.
Failure

11:56:22: Package deploy: Running command '/home/luca/android/sdk/platform-tools/adb -s 373342FC9C0400EC install /home/luca/qt5_dir/t1/android/bin/T1-debug.apk'.
732 KB/s (9256497 bytes in 12.346s)


pkg: /data/local/tmp/T1-debug.apk
----------------------------------------------

Dopo un bel po' di pazienza il programma parte sul Nexus


Nessun commento:

Posta un commento

Arduino logger low power

Alla fine ci sono riuscito La arduino MKR zero e' ormai da un mese che e' rimasta accesa sul tavolo...o meglio si attiva ogni minuto...