I have an expo react native project which shares a common directory with a react web frontend. The common director is in src/common and it is a separate repository, and I use it in the react native project as a git submodule.
I was building fine, but I guess there was an update that broke my builds recently.
The build failes on the first line that is importing from the common directory.
Here is the relevant log from the build (Build Step: Run gradlew)
Welcome to Metro!
Fast - Scalable - Integrated
[stderr] error Unable to resolve module ./src/common/providers/APIErrorProvider from /home/expo/workingdir/build/App.js:
[stderr] None of these files exist:
[stderr] * src/common/providers/APIErrorProvider(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr] * src/common/providers/APIErrorProvider/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr] 8 | // import { StatusBar } from './src/components/status-bar.component'; for some reason this breaks the app
[stderr] 9 | import { Provider } from 'react-redux'
[stderr] > 10 | import APIErrorProvider from './src/common/providers/APIErrorProvider';
[stderr] | ^
[stderr] 11 | import { PersistGate } from 'redux-persist/integration/react';
[stderr] 12 | import configureStore from './src/native-common/storage/configureStore';
[stderr] 13 | import { useFonts, TitilliumWeb_200ExtraLight, TitilliumWeb_300Light, TitilliumWeb_400Regular, TitilliumWeb_700Bold } from '#expo-google-fonts/titillium-web';.
Error: Unable to resolve module ./src/common/providers/APIErrorProvider from /home/expo/workingdir/build/App.js:
None of these files exist:
* src/common/providers/APIErrorProvider(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
* src/common/providers/APIErrorProvider/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
8 | // import { StatusBar } from './src/components/status-bar.component'; for some reason this breaks the app
9 | import { Provider } from 'react-redux'
> 10 | import APIErrorProvider from './src/common/providers/APIErrorProvider';
| ^
11 | import { PersistGate } from 'redux-persist/integration/react';
12 | import configureStore from './src/native-common/storage/configureStore';
13 | import { useFonts, TitilliumWeb_200ExtraLight, TitilliumWeb_300Light, TitilliumWeb_400Regular, TitilliumWeb_700Bold } from '#expo-google-fonts/titillium-web';
at ModuleResolver.resolveDependency (/home/expo/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)
at DependencyGraph.resolveDependency (/home/expo/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
at Object.resolve (/home/expo/workingdir/build/node_modules/metro/src/lib/transformHelpers.js:129:24)
at resolve (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
at /home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
at processModule (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
at async addDependency (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
at async Promise.all (index 2)
info Run CLI with --verbose flag for more details.
> Task :app:bundleReleaseJsAndAssets FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
8 actionable tasks: 8 executed
Unable to list file systems to check whether they can be watched. The whole state of the virtual file system has been discarded. Reason: Could not query file systems: could not open mount file (errno 2: No such file or directory)
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:bundleReleaseJsAndAssets'.
[stderr] > Process 'command 'node'' finished with non-zero exit value 1
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 2m 26s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
Related
BUILD FAILED in 14s
6 actionable tasks: 6 executed
(base) abc#ABCs-MacBook-Pro android %
./gradlew generateCodegenArtifactsFromSchema
Task :app-modules:generateCodegenSchemaFromJavaScript FAILED
/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:3689
throw error;
^
SyntaxError: Unexpected token (10:3)
at instantiate (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:72:32)
at constructor (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:367:12)
at TypeScriptParserMixin.raise (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:3684:19)
at TypeScriptParserMixin.unexpected (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:3723:16)
at TypeScriptParserMixin.tsParseNonArrayType (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:9380:16)
at TypeScriptParserMixin.tsParseArrayTypeOrHigher (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:9384:21)
at /Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:9453:158
at TypeScriptParserMixin.tsInAllowConditionalTypesContext (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:9809:14)
at TypeScriptParserMixin.tsParseTypeOperatorOrHigher (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:9453:114)
at TypeScriptParserMixin.tsParseUnionOrIntersectionType (/Users/abc/JSI-sample-project/SampleApp/node_modules/#babel/parser/lib/index.js:9462:18) {
code: 'BABEL_PARSER_SYNTAX_ERROR',
reasonCode: 'UnexpectedToken',
loc: Position { line: 10, column: 3, index: 303 },
pos: [Getter/Setter]
}
Node.js v18.9.0
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app-modules:generateCodegenSchemaFromJavaScript'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 4s
6 actionable tasks: 1 executed, 5 up-to-date
I upgraded freshchat from "react-native-freshchat-sdk": "^2.6.4" to "react-native-freshchat-sdk": "^4.0.3" and tried running the android app but the build failed with error
Compatible side by side NDK version was not found for android.ndkVersion '22.1.7171670'
> Task :app:compileDebugJavaWithJavac
> Task :app:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
500 actionable tasks: 6 executed, 494 up-to-date
/Users/angellanaigaga/Desktop/numida/trackapp/frontend/trackapp-native/android/app/src/main/java/com/numidatech/numida/NumidaMessagingService.java:3: error: cannot find symbol
import com.freshchat.consumer.sdk.Freshchat;
^
symbol: class Freshchat
location: package com.freshchat.consumer.sdk
/Users/angellanaigaga/Desktop/numida/trackapp/frontend/trackapp-native/android/app/src/main/java/com/numidatech/numida/NumidaMessagingService.java:11: error: cannot find symbol
if (Freshchat.isFreshchatNotification(message)) {
^
symbol: variable Freshchat
location: class NumidaMessagingService
/Users/angellanaigaga/Desktop/numida/trackapp/frontend/trackapp-native/android/app/src/main/java/com/numidatech/numida/NumidaMessagingService.java:12: error: cannot find symbol
Freshchat.handleFcmMessage(this.getApplicationContext(), message);
^
symbol: variable Freshchat
location: class NumidaMessagingService
Note: /Users/angellanaigaga/Desktop/numida/trackapp/frontend/trackapp-native/android/app/src/debug/java/com/numidatech/numida/ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 30s
After digging into the Freshworks and
roid Github, I had to update my App Module gradle file (app/build.gradle) to include freshdesk:freshchat in dependencies like this
dependencies {
implementation 'com.github.freshdesk:freshchat-android:{latestVersion}'
}
...
implementation (project(':react-native-freshchat-sdk')){
exclude group: 'com.github.freshworks'
}
implementation 'com.github.freshdesk:freshchat-android:5.3.3'
These are the logs of the error:
./gradlew :clean :cleanTest :test -Ddebug=true -PenvironmentName=PROD --tests="*dummytest"
> Task :compileKotlin FAILED
e: /home/gpligoropoulos/xm/research_portal/rp_api_automation/src/main/kotlin/Person.kts: (1, 1): No script runtime was found in the classpath: class 'kotlin.script.templates.standard.ScriptTemplateWithArgs' not found. Please add kotlin-script-runtime.jar to the module dependencies.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
3 actionable tasks: 2 executed, 1 up-to-date
The solution is to simply add a single line in dependencies the kotlin script runtime
Similar to here:
dependencies {
...
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-script-runtime
compile group: 'org.jetbrains.kotlin', name: 'kotlin-script-runtime', version: '1.4.10'
...
}
My project's gradle/kotlin directory structure follows the default/recommended approach:
MYPROJ
/src/main/kotlin
app/OnsetsWebapp.kt
Here is the build.gradle.kts : notice we specify mainClassName = app.OnsetsWebapp :
plugins {
application
kotlin("jvm") version "1.3.71"
}
application {
mainClassName = "app.OnsetsWebapp"
}
dependencies {
compile(kotlin("stdlib"))
compile("org.slf4j:slf4j-simple:1.7.25")
compile("io.javalin:javalin:3.8.0")
compile("org.json:json:20160810")
compile("com.j2html:j2html:1.3.0")
}
repositories {
jcenter()
}
Let's build it: ./gradlew build
BUILD SUCCESSFUL in 1s
8 actionable tasks: 5 executed, 3 up-to-date
Now let's run it:
$./gradlew run
This results in
> Task :run FAILED
Error: Could not find or load main class app.OnsetsWebapp
Caused by: java.lang.ClassNotFoundException: app.OnsetsWebapp
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
4 actionable tasks: 1 executed, 3 up-to-date
So why is the class app.OnsetsWebapp not found?
I believe it should be:
application {
mainClassName = "app.OnsetsWebappKt"
}
If you look in the build/classes/kotlin/main/app folder, you should see two class files there: OnsetsWebappKt and OnsetsWebapp. You want to one that has the Kt suffix
Trying to build the a kotlin/js project and getting the following exception:
error package.json: Name contains illegal characters
The project is here:
https://github.com/darran-kelinske-fivestars/cordova-alternative-pattern/tree/kotlin_multiplatform/js
Full output:
3:05:37 PM: Executing task 'build'...
Executing tasks: [build] in project /rom/source/fivestars/CordovaAlternativePattern/js
> Configure project :SharedCode
Kotlin Multiplatform Projects are an experimental feature.
> Task :SharedCode:jsPackageJson
> Task :js:packageJson
> Task :js:testPackageJson
> Task :kotlinNodeJsSetup SKIPPED
> Task :kotlinNpmInstall FAILED
error package.json: Name contains illegal characters
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':kotlinNpmInstall'.
> Process 'Resolving NPM dependencies using yarn' returns 1
yarn install v1.21.1
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 885ms
4 actionable tasks: 4 executed
3:05:38 PM: Task execution finished 'build'.
The issue was with my rootProject.name definition in settings.gradle
I had to change
rootProject.name='Cordova Alternative Pattern'
to
rootProject.name='CordovaAlternativePattern'