I'm using haul as my development server/bundler for a React Native app I am building because I need access to sym links and the standard React Native bundler doesn't give access to them.
I followed the documentation and added:
project.ext.react = [
cliPath: "node_modules/haul/bin/cli.js"
]
to my android/app/build.gradle file and generated the following wepack.haul.js file.
const path = require("path");
module.exports = ({ platform, root }, defaults) => {
return {
entry: `./index.${platform}.js`,
resolve: {
...defaults.resolve,
alias: {
...defaults.resolve.alias,
config: path.join(root, 'config.js')
}
}
}
};
When I run ./gradlew assembleRelease in the android folder of my project directory to generate the .apk file, I get the following error that it couldn't follow the symbolic link.
* What went wrong:
Could not list contents of '/Users/brendan/Projects/<project-name>/node_modules/<team-name>/mart-redux/node_modules/node-pre-gyp/node_modules/.bin/nopt'. Couldn't follow symbolic link.
I'm also getting error messages that my config alias in my webpack.haul file isn't resolving but I believe both of these issues are related.
I believe that the ./gradlew assembleRelease call is using the standard RN packager rather than haul which is why the sym links and alias resolve aren't working properly.
How can I get ./gradlew assembleRelease to use haul?
I'm not sure if this is the proper way to solve the issue but I got haul working in both my local environment and building the .apk file by commenting out the line below in the android/app/build.gradle.
project.ext.react = [
cliPath: "node_modules/haul/bin/cli.js"
]
// apply from: "../../node_modules/react-native/react.gradle"
Related
Recently, we added to our native app a small module of React Native code.
When I follow the instructions in:
https://reactnative.dev/docs/integration-with-existing-apps
It's working fine, the RN module is working as expected.
The problem is that I need to place the RN directory inside the Android directory and not the other way around...
For example, this is how it's currently working:
Projects/ReactNativeProject/Android/
And this is how we need it to work:
Projects/Android/ReactNativeProject
The problem - AutoLinking won't work when I Changed the directories order...
With this CLI error:
Calling `[node, /Users/odedfunt/node_modules/#react-native-community/cli/build/bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
When I add this line to gradle it's not helping:
project.ext.react = [
enableHermes: false, // clean and rebuild if changing
cliPath: ["node", "-e", "console.log(require('react-native/cli').bin);"].execute([], projectDir).text.trim(),
cliPath: "$rootDir/react-native-project/node_modules/react-native/cli.js"
]
this is my settings.gradle
rootProject.name = "ReactTest200"
include ':app'
include ':react-native-svg'
def linkReactSVG = "$rootDir/react-native-project/node_modules/react-native-svg/android"
println("========================= link reactSVG: ${file(linkReactSVG)}")
project(':react-native-svg').projectDir = new File(rootProject.projectDir, linkReactSVG)
def linkSettings = "$rootDir/react-native-project/node_modules/#react-native-community/cli-platform-android/native_modules.gradle"
println("========================= linkSettings: ${file(linkSettings)}")
apply from: file(linkSettings); applyNativeModulesSettingsGradle(settings)
Does anyone knows what's the problem? I've been working on the for days and still couldn't figure it out...
I have followed all steps described here
Here is props of my environment:
react 16.0.0-alpha.6
react-native 0.43.3
react-native-linkedin-sdk 0.0.4
XCode 8.3.2
The Xcode project compiles without issues but I receive an error msg when I invoke the JS code below that the function configure is undefined
Here is my test code:
const config = {
clientID: '<my client id>',
clientSecret: '<my secret>',
state: '<my state hash>',
scopes: 'r_basicprofile',
redirectUri: '<my redirect URL>'
}
const LISDK = LinkedInSDK.configure(config)
The code snipped that causes the error is in LinkedInSessionManager.ios.js
...
const LinkedInSDK = {
configure(config) {
console.info('LINKEDIN SESSION MANAGER', RNLinkedInSessionManager)
return RNLinkedInSessionManager.configure(config);
},
...
};
module.exports = LinkedInSDK;
I added a console output to check whether I get a RNLinkedInSessionManager object but I get an undefined, which means the code of the RNLinkedInSessionManager project is not connected to react-native.
The file RNLinkedInSessionManager.xcworkspace has been successfully added to my XCode project folder under /ios but it seems there is no link to the library.
Any help is much appreciated.
I gave up using the react-native-linkedin-sdk.
Instead I successfully implemented this library react-native-linkedin-login
Nevertheless the library doesn't work without some modifications.
Here my findings:
Android:
I followed all steps here but I received the following error:
Error:Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :react-native-linkedin-login.
It turns out the path described in the above instructions is wrong.
To solve the problem I updated the path in the settings.gradle file like that:
//project(':react-native-linkedin-login').projectDir = new File(rootProject.projectDir, '../../android')
project(':react-native-linkedin-login').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linkedin-login/android')
After that I could successfully build the project.
iOS:
After completing all steps as described here you will have a folder RNLinkedinLogin in your XCode project path.
Drop the LinkedinLogin.m file into the Build Phases -> Compiled Sources
Both files have the old import syntax but since react native 0.40 and above the syntax has changed. You must edit these imports accordingly.
Changed the import in file RNLinkedinLogin.m
// old syntax
//#import "RCTEventDispatcher.h"
// new syntax
#import <React/RCTEventDispatcher.h>
and the import in file 'RNLinkedinLogin.h`
//#import "RCTBridgeModule.h"
#import <React/RCTBridgeModule.h>
Your project will now compile without errors.
Good luck,
Tom
I am using Jenkins to build my android app. i added "Jenkinsfile" in my repo and my current pipeline script looks like this and it is working fine.
node
{
try {
stage("build.clone")
{
checkout scm
}
stage("build.clean")
{
sh "./gradlew clean"
}
stage("build.package")
{
sh "./gradlew assembleDebug"
}
} catch (error) {
throw error
}
}
Now i need to upload my apk to hockeyapp. HockeyApp's Jenkins plugin is installed. And they have made it compatible with pipeline in v 1.2.2
I have googled a lot but found not much help. Kindly guide me or point me to how I can use pipeline script to upload apk to hockeyapp.
Note: I have already created an app on hockey app and I have app token and app id. Also i know curl command is available but i want to use hockeyapp plugin with pipeline
You should be able to get the syntax for just about any Pipeline step via the snippet generator built in to Jenkins.
Doing so in my Jenkins install gives me something like this (horrifying) syntax:
step([$class: 'HockeyappRecorder',
applications: [[downloadAllowed: false, mandatory: false,
notifyTeam: false, releaseNotesMethod: [$class: 'NoReleaseNotes'],
uploadMethod: [$class: 'AppCreation', publicPage: false]]],
debugMode: false, failGracefully: false])
I'm building an Android application using Jenkins pipeline and Gradle.
I'd like to run Lint tests on the code and so the command which is used for that matter is:
./gradlew lintStagingDebug
For some reason this Gradle task is not creating the report.
I know that if I'd run lint like so:
lint <project_dir> --xml xml_dest_path
It would create the report.
But since through out the whole pipeline I'm using gradlew to run the relevant tasks (clean, lint, compile, unittest, assemble) I'd like to use gradlew for this task as well but I'm not sure how to tell Gradle to export the lint report.
Another thing I've tried is to edit the project/build.gradle file and change this section:
lintOptions {
abortOnError false
}
to (according to Lint official documentation)
lintOptions {
abortOnError false
xmlOutput projectDir/lint-results.xml
}
But then I get an error:
A problem occurred evaluating project ':App01'.
> No signature of method: java.io.File.div() is applicable for argument types: (com.android.build.gradle.tasks.Lint_Decorated) values: [task ':App01:lint']
Anyone knows how it can be done?
You can provide the XML report output file in Gradle in the following way:
lintOptions {
xmlOutput file("lint-results.xml")
}
The xmlOutput method requires a file type argument. I have used the relative path in the argument. You can also use it with projectDir.
lintOptions {
xmlOutput file("$projectDir/lint-results.xml")
}
Here's how I solved it.
stage('Lint run') {
sh """
export HOME=$GRADLE_USER_HOME
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
OUTPUTFILE="lint-results.txt"
touch \$OUTPUTFILE
./gradlew lint${BUILDFLAV}${BUILDTYPE} -x lint 2>&1 | tee \$OUTPUTFILE
"""
})
Explanation:
In order to keep using gradlew to run lint test on the code, I've defined an output file and added at the end of the gradlew command redirection of stdOut and stdErr to this output file using the Linux command "tee".
I'm trying to run my react native android app in debug mode on our devices, without the need for a dev server running on a dev box. I'm using the debug variant/scheme on both platforms to facilitate the "staging" version of our app, since I've read that react native is not super friendly with build modes other than release and debug.
On the iOS side, I was able to modify the AppDelegate.m as follows... basically, if it's a debug build and it was built by buddybuild, don't look for a dev machine for the js bundle, look to the device:
#ifdef DEBUG
NSDictionary *infoPlistDict = [[NSBundle mainBundle] infoDictionary];
if (infoPlistDict[#"BUDDYBUILD_BUILD_ID"]) {
// deployed via buddybuild, don't use localhost
jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];
} else {
jsCodeLocation = [NSURL URLWithString:#"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
}
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];
#endif
... I'm looking for a way to do this on android. I have the buddybuild bit of code I need, so no worries there, I just want to know how to programmatically change the location of the js bundle on android as I do above for iOS in AppDelegate.m. Right now, all code related to the location of the js bundle on android seems to be in the react-native package itself and I'd rather not hack that to get it to work.
If I can provide any more information, please let me know.
I would like to summarize the solution to bundle everything within a debug build. Especially the hint in point two did the trick for me. Thanks #Tspoon.
1. Android Studio
go to Preferences -> Build, Execution, Deployment -> Compiler
uncheck "Configure on Demand"
2. build.gradle
within your app/build.gradle file do the following:
project.ext.react = [
// whether to bundle JS and assets in debug mode
bundleInDebug: true,
// whether to bundle JS and assets in release mode
bundleInRelease: true,
]
apply from: "../../node_modules/react-native/react.gradle"
NOTE that it is important to define the react settings above the apply from ... statement, otherwise it will not work
3. Create APK
create your dev apk as usual with ./gradlew assembleDebug within your android folder
On Android, you'll want to modify android/app/build.gradle.
Before the apply from: "../../node_modules/react-native/react.gradle" line, you'll want to tell the packager to bundle the js assets and include them when deploying your APK.
For example:
project.ext.react = [
bundleInBuddybuild: true,
]
Where the syntax is bundleIn${productFlavor}${buildType}
Or if you just want to do it for for debug builds:
project.ext.react = [
bundleInDebug: true,
]