NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
524 stars 134 forks source link

Build fails on MacOS #448

Closed PeterStaev closed 8 years ago

PeterStaev commented 8 years ago

Steps to reproduce:

  1. Checkout https://github.com/PeterStaev/nativescript-azure-mobile-apps
  2. run npm install and grunt build in the root folder
  3. run tns build android in the sample directory.

On Mac I get the following output (runs fine on Windows 10 and Travis linux distros):

:asbg:runAstParser
couldn't find logDirectory so it will be created in place:/Users/peter/Documents/Projects/nativescript-azure-mobile-apps/sample/platforms/android/build-tools/android-static-binding-generator/ast-parser/logs/i.txt
inputDir: /Users/peter/Documents/Projects/nativescript-azure-mobile-apps/sample/platforms/android/src/main/assets/app
outFile: ../bindings.txt
:asbg:generateBindings
:generateF0F1DebugAssets UP-TO-DATE
:mergeF0F1DebugAssets
:generateF0F1DebugResValues
:generateF0F1DebugResources
:mergeF0F1DebugResources
:processF0F1DebugManifest
:processF0F1DebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processF0F1DebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/opt/android-sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
Plamen5kov commented 8 years ago

Hi @PeterStaev Try updating the build-tools from the Android SDK Manager.

PeterStaev commented 8 years ago

Hi @Plamen5kov , already tried that: tried both 23.0.2 and 23.0.3 but on both the same error pops up.

Plamen5kov commented 8 years ago

Do a tns prepare android and go to platforms/android folder and run gradlew buildapk --info and post the output here.

PeterStaev commented 8 years ago

https://gist.github.com/PeterStaev/e404590944ba4c2b95bc82c5707cf2fc

Plamen5kov commented 8 years ago

Hi @PeterStaev, I couldn't reproduce the problem on either platform, but what I can see from the log, your problem seems to reside in:

/Users/peter/Documents/Projects/nativescript-azure-mobile-apps/sample/platforms/android/build...

Try deleting the build folder and try to build again.

PeterStaev commented 8 years ago

Hi @Plamen5kov Sadly no go. And moreover now i see this happening on Windows as well :( Here are the details from the windows machine:

Executing task ':processF0F1DebugResources' (up-to-date check took 0.364 secs) due to:
  No history is available.
All input files are considered out-of-date for incremental task ':processF0F1DebugResources'.
Starting process 'command 'C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\aapt.exe''. Working directory: T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android Command: C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\aapt.exe package -f --no-crunch -I C:\Program Files (x86)\Android\android-sdk\platforms\android-23\android.jar -M T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\manifests\full\F0F1\debug\AndroidManifest.xml -S T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\res\merged\F0F1\debug -A T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\assets\F0F1\debug -m -J T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\generated\source\r\F0F1\debug -F T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\res\resources-F0-F1-debug.ap_ --debug-mode --custom-package inc.tangra.azuremobileservicessample -0 apk --no-version-vectors --output-text-symbols T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\symbols\F0F1\debug
Successfully started process 'command 'C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\aapt.exe''
Unknown source file :       Unable to add 'T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\assets\F0F1\debug\app\tns_modules\semver\semver.browser.js.gz': file already in archive (try '-u'?)

Unknown source file : ERROR: unable to process assets while packaging 'T:\_MISC\nativescript-azure-mobile-apps\sample\platforms\android\build\intermediates\res\resources-F0-F1-debug.ap_'

:processF0F1DebugResources FAILED
:processF0F1DebugResources (Thread[main,5,main]) completed. Took 2.278 secs.

From what I see the problem is that there are .gz files included in the assets. For Mac I'm not sure from where that tar-pack dependency comes, but on Windows I see that the karma@0.13.22 module has reference to log4js@0.6.36 which has refrence to semver@4.3.6 and in the semver module there are two files: semver.min.js.gz and semver.browser.js.gz and for some reason those get copied over on prepare to the android/src/main/assets/app/tns_modules as modules which does not seem right.

So seems this issue relates more to the CLI than to the android runtime?

PeterStaev commented 8 years ago

Seems there is already an opened issue on the CLI repo: https://github.com/NativeScript/nativescript-cli/issues/1740. Using hdeshev's workaround to use tns install instead of npm install for the project fixes the issue.

Plamen5kov commented 8 years ago

Hi @PeterStaev, The server.min.js and server.browser.js.gz come from the karma module, which is declared as a dev dependency and should not be packed with the final .apk, but CLI still copies it into the platforms/android folder, which causes the problems. You are right to think it's a CLI problem. When I tried reproducing the problem, I was using CLI 2.0.0, so you try to update CLI and try again.

PeterStaev commented 8 years ago

I am using CLI 2.0 as well.