shirakaba / react-nativescript

React renderer for NativeScript
https://react-nativescript.netlify.com
MIT License
280 stars 14 forks source link

Build error when generating android apk with nativescript sidekick #45

Closed Lelelo1 closed 4 years ago

Lelelo1 commented 4 years ago

First of all I had to downgrade node to be able to start the build process with nativescript sidekick.

When building apk in release I get the following error

(CLI) TypeError: Cannot read property 'dispatch' of undefined node_modules/fork-ts-checker-webpack-plugin/src/index.ts:690:60

Build failed. Executing webpack failed with exit code 1.

I have noticed that the "fork-ts-checker-webpack-plugin": "^1.3.7" module which is a dependency of my react-nativescript app has a node_modules/fork-ts-checker-webpack-plugin/lib/index path, not node_modules/fork-ts-checker-webpack-plugin/src/index.

I have the following webpack in my package.json: "nativescript-dev-webpack": "1.0.1"

shirakaba commented 4 years ago

I have noticed that the "fork-ts-checker-webpack-plugin": "^1.3.7" dependency of my react-nativescript app has a */lib/index path, not */src/index.

Not sure what you mean by this part.

Is the error resolved by doing the usual:

Lelelo1 commented 4 years ago

I have the same error

/myproject/node_modules/fork-ts-checker-webpack-plugin/src/index.ts:690:60)

There was a warning about having two webpack.config.js when npm install. But I think fork-ts-checker-webpack-plugin might have to be downgraded as there is no src folder in the module.

I will look into it more closely tomorrow.

Lelelo1 commented 4 years ago

There does not seem to be any src folder in any of the npm releases of fork-ts-checker-webpack plugin. Running build without it being installed I get a complaint that the module can't be found.

The GitHub repo has src/index.ts.

I suspect that nativescript-dev-webpack might have been developed with git+https://github.com/TypeStrong/fork-ts-checker-webpack-plugin.git against some early version.

Also, I have noticed fork-ts-checker-webpack-plugin is not a dependency of a new nativescript typescript project

Looking into nativescript-dev-webpack, it has "fork-ts-checker-webpack-plugin": "2.0.0" as dependency. When building with 2.0.0 I got past the previous error and got the following:

[19-11-12 14:32:04.175] (CLI) ✖ 「atl」: Checking finished with 4 errors [19-11-12 14:32:07.271] Build failed. Executing webpack failed with exit code 2.

Those 4 error mentioned are type check errors - that I will try to deal with with. The webpack failure has no further information given to it.

Lelelo1 commented 4 years ago

After resolving the errors in the project - that also could be seen when tns run ios/android - I was able to get past:

(CLI) TypeError: Cannot read property 'dispatch' of undefined node_modules/fork-ts-checker-webpack-plugin/src/index.ts:690:60 Build failed. Executing webpack failed with exit code 1.

The version I used was "fork-ts-checker-webpack-plugin": "^1.3.7".


Now I am getting into another error:

Build failed. Only 8, 16, 24, or 32 bits supported: 872

But it is documented here

shirakaba commented 4 years ago

First of all, shall we try building it without fork-ts-checker-webpack-plugin at all, to see whether that's the source of the problem or not? The plugin is only there to speed up incremental TS builds anyway (and even then, I didn't perceive that it sped things up by much); it's otherwise totally removable.

Just comment-out these lines from webpack.config.js:

https://github.com/shirakaba/tns-template-blank-react/blob/master/webpack.config.js#L310-L315

Lelelo1 commented 4 years ago

I suspect the initial error was caused by having type errors in the code of the project.

Commenting out webpack.config.js I still get the new error:

[19-11-13 10:59:55.827] Upload step started. [19-11-13 10:59:57.082] (CLI) Unable to use git, reason is: [19-11-13 10:59:57.085] (CLI) Command /usr/local/bin/git failed with exit code 128 Error output: [19-11-13 10:59:57.085] (CLI) fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/sk-builds-f2d125fdaf242de46b1e83990ad11168ed5853c4/': The requested URL returned error: 403 [19-11-13 11:00:17.163] Upload step completed. [19-11-13 11:00:18.627] Build failed. Only 8, 16, 24, or 32 bits supported: 872

I just made some bad things to my package.jsonso I will pobably git reset. The initial error might pop up again I will report if so later today.

shirakaba commented 4 years ago

NativeScript CLI uses git to diff certain things (I don't know the details), so I guess that this is an issue for the NativeScript CLI repo. I think that, for whatever reason, it's failing to download one of your previous incremental builds that are hosted on AWS. A git reset might be a good first step, as you say.

To be honest, last time I published a NativeScript app to the iOS App Store, I couldn't get it to publish through the NativeScript CLI either. I opened up the generated native app project (Xcode project) and published it as one would publish a native app (via Xcode, in my case).

Lelelo1 commented 4 years ago

I got a successful build:

First of all I did not have JAVA_HOME set, I don't know why nativescript (or flutter) never complained.

The android certificate key is to be key.p12 while the command in the flutter documentation generates a .jks. Here someone said converting from jks to p12 did not help. But as the flutter docs say if java 9 or higher is used - the key is generated as PKS12 directly.

The new key came out as jks though so it could have been that JAVA_HOME was not set, or it was Java version should be 9 or higher.


shirakaba commented 4 years ago

@Lelelo1 Well done for solving it! Sounds like it was an intricate problem to solve. I've had problems with JAVA_HOME before, partially due to install scripts not doing their job properly, and partially due to running a multi-user setup or having conflicting environment variables for NativeScript development and native development. Hope I never have to touch that stuff again.

I'll keep that android certificate stuff in mind for when I get round to doing any Android releases; thanks!

Lelelo1 commented 4 years ago

When updating to NativeScript v6.2.x. I could no longer run my app in debug on android. So after producing that certificate with a java 9 or higher - I had to go back using java 8 (to run in debug)

shirakaba commented 4 years ago

@Lelelo1 I think that sounds more like a cache problem (and can only advise cleaning your Android debug build and building afresh). More an issue for the NativeScript side rather than React NativeScript specifically, I think as well.