phonegap / phonegap-cli

PhoneGap and PhoneGap/Build command-line interface
Apache License 2.0
491 stars 156 forks source link

Incomplete Android Build on Windows #145

Closed tolu360 closed 10 years ago

tolu360 commented 11 years ago

I updated node and npm versions to the latest (0.10.15 and 1.3.5 respectively) and then I reinstalled phonegap-cli and subsequently have been having issues using the tool on my Windows PC.

Each time I create and build/run a project I get 'success' messages but each time the process seemed to have ended abruptly without any errors indicated.

A look into the compiled android platform bin folder reveals just these content without any apk files: /classes /dexedLibs /res -AndroidManifest.xml -AndroidManifest.xml.d -jarlist.cache -proguard.txt

I have deleted my root .cordova directory severally just to force the tool to download new files. Have used the --verbose flag with my commands to see if any error would be reported but none.

My last rebuild command yielded the following --verbose output:

C:\myapp2>phonegap build android --verbose [phonegap] detecting Android SDK environment... [phonegap] Checking Android requirements... [phonegap] Running "android list target" (output to follow)

[phonegap] Available Android targets:

id: 1 or "android-10" Name: Android 2.3.3 Type: Platform API level: 10 Revision: 2 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854

ABIs : armeabi

id: 2 or "android-13" Name: Android 3.2 Type: Platform API level: 13 Revision: 1 Skins: WXGA (default)

ABIs : armeabi

id: 3 or "android-14" Name: Android 4.0 Type: Platform API level: 14 Revision: 3 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800

ABIs : no ABIs.

id: 4 or "android-15" Name: Android 4.0.3 Type: Platform API level: 15 Revision: 3 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800

ABIs : no ABIs.

id: 5 or "android-16" Name: Android 4.1.2 Type: Platform API level: 16 Revision: 4 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in

ABIs : no ABIs.

id: 6 or "android-17" Name: Android 4.2.2 Type: Platform API level: 17 Revision: 2 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in ABIs : armeabi-v7a

[phonegap] Running "android update project -p "C:\Users\TOLU.cordova\lib\android\cordova\3.0.0\framework" -t android-17" (output to follow)... [phonegap] Updated project.properties Updated local.properties build.xml: Found version-tag: custom. File will not be updated. Updated file C:\Users\TOLU.cordova\lib\android\cordova\3.0.0\framework\proguard-project.txt It seems that there are sub-projects. If you want to update them please use the --subprojects parameter.

[phonegap] using the local environment [phonegap] compiling Android... [phonegap] cordova library for "android" already exists. No need to download. Continuing. [phonegap] Wrote out Android application name to "MyTodos" [phonegap] Wrote out Android package name to "com.phonegap.mytodos" [phonegap] Calling plugman.prepare for platform "android" [phonegap] Compiling platform "android" with command ""C:\myapp2\platforms\android\cordova\build"" (output to follow)... [phonegap] Cleaning project... WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug. Buildfile: C:\myapp2\platforms\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env: [checkenv] Android SDK Tools Revision 22.0.4 [checkenv] Installed at C:\pg\sdk

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup: [getbuildtools] Using latest Build Tools: 17.0.0 [echo] Resolving Build Target for MyTodos... [gettarget] Project Target: Android 4.2.2 [gettarget] API level: 17 [echo] ----------

[phonegap] Platform "android" compiled successfully. [phonegap] successfully compiled Android app

Please help!

mwbrooks commented 11 years ago

Hi @tolu360

Thanks for all the detail!

Your output looks good. Do you happen to have an .apk file in the following directory (e.g. Todos.apk):

C:\myapp2\platforms\android\bin\

As a heads up, the build command does just that - it builds your project and nothing more.

You may want to use the run command to both build & install the app.

Try:

$ phonegap run android

If that doesn't help, can you paste the output from:

$ phonegap run android --verbose

+@ryanstewart to stay in the loop on current phonegap-cli issues.

tolu360 commented 11 years ago

No .apk at all.

I just pasted my last command, I'm quite aware that the run command does both build and install. Here is the output of the run command:

C:\myapp2>phonegap local run android --verbose

[phonegap] compiling Android... [phonegap] cordova library for "android" already exists. No need to download. Continuing. [phonegap] Wrote out Android application name to "MyTodos" [phonegap] Wrote out Android package name to "com.phonegap.mytodos" [phonegap] Calling plugman.prepare for platform "android" [phonegap] Compiling platform "android" with command ""C:\myapp2\platforms\android\cordova\build"" (output to follow)... [phonegap] Cleaning project... WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug. Buildfile: C:\myapp2\platforms\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env: [checkenv] Android SDK Tools Revision 22.0.5 [checkenv] Installed at C:\pg\sdk

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup: [getbuildtools] Using latest Build Tools: 17.0.0 [echo] Resolving Build Target for MyTodos... [gettarget] Project Target: Android 4.2.2 [gettarget] API level: 17 [echo] ---------- [echo] Creating output directories if needed...

[phonegap] Platform "android" compiled successfully. [phonegap] successfully compiled Android app [phonegap] trying to install app onto device [phonegap] cordova library for "android" already exists. No need to download. Continuing. [phonegap] Wrote out Android application name to "MyTodos" [phonegap] Wrote out Android package name to "com.phonegap.mytodos" [phonegap] Calling plugman.prepare for platform "android" [phonegap] Running app on platform "android" with command ""C:\myapp2\platforms\android\cordova\run" --device" (output to follow)... [phonegap] Cleaning project... WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug. Buildfile: C:\myapp2\platforms\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env: [checkenv] Android SDK Tools Revision 22.0.5 [checkenv] Installed at C:\pg\sdk

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup: [getbuildtools] Using latest Build Tools: 17.0.0 [echo] Resolving Build Target for MyTodos... [gettarget] Project Target: Android 4.2.2 [gettarget] API level: 17 [echo] ---------- Error : No devices found to install to, make sure there are devices availible by checking '\cordova\lib\list-devices'

[phonegap] Platform "android" ran successfully. [phonegap] successfully installed onto device

mwbrooks commented 11 years ago

Hmm...

Okay, well your build is certainly ending too quickly. After:

[gettarget] API level: 17
[echo] ----------

There is more build setup tasks, along with the actual act of compiling the code.

Well, let's remove one layer of abstraction and try to use the Android SDK directly.

$ cd platforms\android
$ ant debug

Let's see if that output is any different. In an ideal world, it should be identical to the output produced by --verbose.

tolu360 commented 11 years ago

Hi @mwbrooks

Here is my output from running 'ant debug' --

C:\myapp2>cd platforms/android

C:\myapp2\platforms\android>ant debug Buildfile: C:\myapp2\platforms\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env: [checkenv] Android SDK Tools Revision 22.0.5 [checkenv] Installed at C:\pg\sdk

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup: [getbuildtools] Using latest Build Tools: 17.0.0 [echo] Resolving Build Target for MyTodos... [gettarget] Project Target: Android 4.2.2 [gettarget] API level: 17 [echo] ---------- [echo] Creating output directories if needed... [echo] ---------- [echo] Resolving Dependencies for MyTodos... [dependency] Library dependencies: [dependency] No Libraries [echo] ---------- [echo] Building Libraries with 'debug'... [subant] No sub-builds to iterate on

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

-pre-compile:

-compile: [javac] Compiling 2 source files to C:\myapp2\platforms\android\bin\classes

-post-compile:

-obfuscate:

-dex: [dex] input: C:\myapp2\platforms\android\bin\classes [dex] input: C:\myapp2\platforms\android\libs\cordova-3.0.0.jar [dex] Pre-Dexing C:\myapp2\platforms\android\libs\cordova-3.0.0.jar -> cordova-3.0.0-f6ac77a59726ef8ce3941534a874ba57.jar [dx] Error occurred during initialization of VM [dx] Error: Could not create the Java Virtual Machine.Could not reserve enough space for object heap [dx] [dx] Error: A fatal exception has occurred. Program will exit.

BUILD FAILED C:\pg\sdk\tools\ant\build.xml:884: The following error occurred while executing this line: C:\pg\sdk\tools\ant\build.xml:886: The following error occurred while executing this line: C:\pg\sdk\tools\ant\build.xml:898: The following error occurred while executing this line: C:\pg\sdk\tools\ant\build.xml:281: null returned: 1

Total time: 4 seconds

C:\myapp2\platforms\android>

mwbrooks commented 11 years ago

@tolu360

Looks like the culprit in Java VM memory heaps:

[dx] Error occurred during initialization of VM
[dx] Error: Could not create the Java Virtual Machine.Could not reserve enough space for object heap
[dx]
[dx] Error: A fatal exception has occurred. Program will exit.

A quick Google shows that you can provide a switch to boost the Java VM heap size. I'm not a Java expert, so I'm not sure what the easiest approach is to globally boost your Java VM heap.

I'll think on it. Let me know if you come up something!

+@ryanstewart

tolu360 commented 11 years ago

Hi @mwbrooks

I never got around increasing my Java VM memory heap but my local android build worked after restarting my PC.

Please whats the suggested work-around for getting splash screens to work with the phonegap cli? I have tried copying images into the res folder in platfroms/android, the build failed each time I did that. What do you advise?

tolu360 commented 11 years ago

Update: I figured it out already. A quick work-around for splash screens is to copy the images into platforms/android/res and ensure they are all named splash.png and pretty much follow the instructions here...

http://docs.phonegap.com/en/3.0.0/cordova_splashscreen_splashscreen.md.html

lorinbeer commented 10 years ago

Closing this issue off as it seems you two managed to resolve the problem.