NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 195 forks source link

Build failing on android with 2.4.0 #2258

Closed enchev closed 7 years ago

enchev commented 7 years ago

From @NgSculptor on November 22, 2016 7:31

Did you verify this is a real problem by searching [Stack Overflow]

Yes

Tell us about the problem

Build is failing on android after update

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

This is the package.json file that I have:

"nativescript": {
    "id": "io.egen.protec",
    "tns-ios": {
      "version": "2.4.0"
    },
    "tns-android": {
      "version": "2.4.0"
    }
  },
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/platform-server": "2.0.0",
    "@angular/router": "3.0.0",
    "email-validator": "^1.0.7",
    "lodash": "^4.16.6",
    "nativescript-angular": "1.0.0",
    "nativescript-background-http": "^2.4.0",
    "nativescript-camera": "0.0.8",
    "nativescript-drop-down": "^1.4.0",
    "nativescript-email": "^1.3.3",
    "nativescript-imagepicker": "^2.4.1",
    "nativescript-iqkeyboardmanager": "^1.0.1",
    "nativescript-ng2-fonticon": "^1.3.3",
    "nativescript-permissions": "^1.2.1",
    "nativescript-phone": "^1.2.3",
    "nativescript-social-share": "^1.3.1",
    "nativescript-swiss-army-knife": "^1.0.71",
    "nativescript-telerik-ui-pro": "^1.4.1",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.12",
    "tns-core-modules": "^2.4.0"
  },
  "devDependencies": {
    "babel-traverse": "6.9.0",
    "babel-types": "6.9.0",
    "babylon": "6.8.0",
    "filewalker": "0.1.2",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "^0.3.2",
    "typescript": "^2.0.10",
    "zone.js": "0.6.21"
  }

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

This is the console output

:asbg:runAstParser
Running full build
finished with reading lines with js files
Warning: there already is an extend called com.tns.NativeScriptActivity.
Warning: there already is an extend called com.tns.FragmentClass.
:asbg:generateBindings
:mergeF0F1F2F3F4F5DebugShaders
:compileF0F1F2F3F4F5DebugShaders
:generateF0F1F2F3F4F5DebugAssets
:mergeF0F1F2F3F4F5DebugAssets
:generateF0F1F2F3F4F5DebugResValues
:generateF0F1F2F3F4F5DebugResources
:mergeF0F1F2F3F4F5DebugResources
:processF0F1F2F3F4F5DebugManifest
:processF0F1F2F3F4F5DebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processF0F1F2F3F4F5DebugResources'.
> Error: more than one library with package name 'com.telerik.android.data'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 30.926 secs
Command /Users/xyz/abc/platforms/android/gradlew failed with exit code 1

Not sure if related, but I started seeing this warning message for both ios and android

Could not find folder: /Users/xyz/abc/platforms/ios/protec/app/tns_modules/tns-core-modules

Copied from original issue: NativeScript/NativeScript#3139

enchev commented 7 years ago

From @tsonevn on November 22, 2016 7:41

Hi @NgSculptor, Try to upgrade the dependencies in your project package.json file as following the below-attached code snippet.

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.sample3139"
  },
  "dependencies": {
    "@angular/common": "2.1.2",
    "@angular/compiler": "2.1.2",
    "@angular/core": "2.1.2",
    "@angular/forms": "2.1.2",
    "@angular/http": "2.1.2",
    "@angular/platform-browser": "2.1.2",
    "@angular/platform-browser-dynamic": "2.1.2",
    "@angular/router": "3.1.2",
    "nativescript-angular": "1.1.3",
    "nativescript-theme-core": "^0.2.1",
    "reflect-metadata": "~0.1.8",
    "rxjs": "5.0.0-beta.12",
    "tns-core-modules": "2.4.0"
  },
  "devDependencies": {
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-typescript": "^0.3.2",
    "typescript": "^2.0.10",
    "zone.js": "~0.6.21"
  }
}

Delete node_modules, platforms, hooks folders and clear npm cache npm cache clear. Then rebuild your project with tns run android.

Hope this helps.

enchev commented 7 years ago

From @NgSculptor on November 22, 2016 8:1

@tsonevn still getting the same error. I already tried what you have mentioned above, just copy pasted your package.json file just to be sure.

enchev commented 7 years ago

From @NgSculptor on November 22, 2016 8:31

@tsonevn I also noticed that the TS files are not longer compiled into JS files. Looks like something else is also messed up. Im using the package.json that you specified

enchev commented 7 years ago

From @NathanaelA on November 22, 2016 10:25

@tsonevn - I can confirm this issue on iOS; I don't understand the full reasons why yet.

I am using the latest TypeScript both installed as a Dev Dependency and Globally (2.0.10), and the latest ns-dev-typescript (0.3.3), along with 2.4 of Runtimes, common core, and tns command line program.

I took a project that worked perfectly in 2.3 and upgraded it to 2.4 and it seems to have issues deciding when (or if) it will build any TS in JS. Using tns run ios --emulator --watch or tns livesync ios --emulator --watch does not WATCH (nor appear to build) any of the TS files. Any JS I manually change does get synced, and changing the tsconfig file does cause a resync, but changing any TS files does NOT cause any rebuilding to happen.

A couple notes: TNS ... --watch does report Compilation complete. Watching for file changes. so it is acting like tsc is loaded and watching properly. (And according to ps it is running: 501 2870 2844 0 12:27AM ttys002 12:00.62 /usr/local/bin/node --max_old_space_size=2048 /Users/mac/Source/project/node_modules/typescript/lib/tsc.js --project /Users/mac/Source/project --watch) However, it is not doing anything.

Work around: If I open up a second command prompt; switch to the project/app folder and then type tsc -w it gives me the same watching message Compilation complete. Watching for file changes. but it actually works, and see's any .ts file changes. (Same thing if I run tsc in there, it builds the whole project properly)

More Notes

enchev commented 7 years ago

From @NgSculptor on November 22, 2016 15:50

@NathanaelA Just to confirm, you are not having any issues with Android builds? Can you share your dependencies?

enchev commented 7 years ago

From @NathanaelA on November 22, 2016 20:19

@NgSculptor - To be honest I have NO idea if the Android LiveSync side works. Before Telerik actually created their LiveSync for NativeScript, I wrote my own (nativescript-liveedit); which is currently for only Android. I use my LiveEdit on Android exclusively because it offers many features including being considerably faster than the built in LiveSync. So I have NO idea if LiveSync on Android works, no need to use it. :-)

I haven't done any work to make it work on iOS; so I still have to use Telerik's LiveSync on iOS. But you can get around the issue if you do what I said above... This actually appears to be primarily an upstream TSC bug, not a NativeScript bug (per sey). But can be worked around by Telerik if they point it to the /app folder.

enchev commented 7 years ago

From @NathanaelA on November 22, 2016 21:21

@NgSculptor - Which version of Node are you using. I'm using 5.11?

enchev commented 7 years ago

From @NgSculptor on November 23, 2016 0:26

@NathanaelA I am on v4.4.5, the only solution for me right now was to revert to 2.3.0

enchev commented 7 years ago

From @NathanaelA on November 23, 2016 2:35

Hmm, I also tested the current 6.9.1, didn't make a difference... I'm not sure why TSC doesn't want to work properly. Fortunately the workaround I listed does work in 2.4, a bit of an annoyance...

enchev commented 7 years ago

From @tsonevn on November 24, 2016 14:29

Hi @NgSculptor ,

I research further this problem and found that this problem could be caused due to haveing nativescript-imagepicker and nativescript-telerik-ui plugins in the same time in your project. The image picker plugin has a dependency for nativescript-telerik-ui, because RadListView component has been used in the plugin. Regarding to that, could you verify, whether removing `nativescript-imagepicker will resolve your problem with building the application for android. We will investigate this problem deeper and will provide possible solution for using the both plugin in the same time. You should also upgrade the dependencies in your example by following the given code snippet from my previous comment.

Regards, @tsonevn

enchev commented 7 years ago

From @NathanaelA on November 25, 2016 4:15

Actually I ran into another reason which I posted on my blog; when I have a few more minutes I'll try and detail the reason it was broken for me here...

dtopuzov commented 7 years ago

Conflict between nativescript-imagepicker and nativescript-telerik-ui-pro already solved.