I'm trying to setup a build process that can run when our dev commits to the GitLab repository. I'm trying to get this thing to build the APK and the method that I'm using for this is suggested by this thread the error I'm getting is here which implies that the file aapt doesn't exist. Although investigating that path it most certainly exists so I have no idea what I'm doing wrong here.
The docker container that I'm using as a base is /runmymind/docker-android-sdk/:latest then I'm using this dockerfile at /chamunks/ReactNativeAndroid/
I'm not entirely certain how I'm failing at this as I've never compiled an android app before but this process being as crazy as it is makes me wonder how anyone ever builds an android app.
You can try deleting android/build and android/app/build directories and then call gradle to build and install the app.
For Debug you should call these in your project root directory;
(cd android/ && ./gradlew assembleDebug)
(cd android/ && ./gradlew installDebug)
For Release you should call these in your project root directory. This option needs a generated .keystore file. The produced .apk files are under android/app/build/outputs/apk path;
(cd android/ && ./gradlew assembleRelease)
(cd android/ && ./gradlew installRelease)
You might also try reinstalling your android-sdk. You might have a problem with version 23.0.3.
Related
I’m in the middle of moving my iOS app’s Firebase dependency from CocoaPods to Swift Package Manager.
Firebase’s Crashlytics requires a script to be executed while the app is building (using the Run Script build phase). Back in the CocoaPods days, I used to call the script the way documented by Google: "${PODS_ROOT}/FirebaseCrashlytics/run".
After I’ve switched to SPM, Firebase files are no longer in ${PODS_ROOT}, and there’s no such variable available at all. I know the file I need is now located in the DerivedData folder, specifically it’s at ~/Library/Developer/Xcode/DerivedData/MyApp-abcde/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run. The problem is, the MyApp-abcde folder is not easily referenced.
A Medium post I found suggested using the ${BUILD_DIR} build variable (in regard to the example above, it would resolve to <…>/MyApp-abcde/Build/Products), and calling the dirname command to move up the directory hierarchy.
This hack worked only for running the app. When I tried to archive it, ${BUILD_DIR} resolved to another path, namely <…>/MyApp-abcde/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath. I tried a few more build variables, such as ${SYMROOT}, in place of ${BUILD_DIR}, but they also produce different paths depending on the operation.
So, here comes the question…
Is there a way to reliably reference my app’s derived data folder’s root (i.e. ~/Library/Developer/Xcode/DerivedData/MyApp-abcde) using Xcode’s build variables?
You were close. This should work:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
Crashlytics run script
To build&run from Xcode:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
To archive for distribution from Xcode Server at CI/CD:
${XCS_DERIVED_DATA_DIR%/*}/Dependencies/checkouts/firebase-ios-sdk/Crashlytics/run
To work for both at the same time:
if [[ "${XCS_DERIVED_DATA_DIR}" == "" ]]; then
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
else
${XCS_DERIVED_DATA_DIR%/*}/Dependencies/checkouts/firebase-ios-sdk/Crashlytics/run
fi
I'm reworking my answer as I realized I haven't answered your question..
I have a run script that copies the build targets into a new folder. This works for both Build and Archive. Note that you need the -L on copy to follow the symlink
# Copy the built framework into a sibling to the project folder
if [[ "$CONFIGURATION" == "Debug" ]]; then
mkdir -p "$PROJECT_DIR/../../iwins-ios-sdk/debug"
rm -rf "$PROJECT_DIR/../../iwins-ios-sdk/debug/IWiNS_SDK.framework"
cp -LR "$BUILD_DIR/Debug-iphoneos/IWiNS_SDK.framework" "$PROJECT_DIR/../../iwins-ios-sdk/debug"
else
mkdir -p "$PROJECT_DIR/../../iwins-ios-sdk/release"
rm -rf "$PROJECT_DIR/../../iwins-ios-sdk/release/IWiNS_SDK.framework"
cp -LR "$BUILD_DIR/Release-iphoneos/IWiNS_SDK.framework" "$PROJECT_DIR/../../iwins-ios-sdk/release"
fi
Also, you can find all of the build envvars here:
https://gist.github.com/gdavis/6670468
So, it appears that $BUILD_DIR is different for build/release, but by copying the files to a known location at build time, you'll know where to find them.
How to generate gradlew file to Jenkins Android Project? My project is not Android Native. My project is Flutter.
I try to create CD with Jenkins and I got some errors.
this is my pipeline code (JenkinsFile)
stage('Build Release APK') {
sh "ls ./android"
sh "./android/gradlew clean assembleRelease"
}
ls output is,(There is not gradlew file)
ls ./android
app
build.gradle
gradle
gradle.properties
key.properties
settings.gradle
This is an error I got
./android/gradlew clean assembleRelease
/Users/donperera/.jenkins/workspace/demo#tmp/durable-b0592b49/script.sh: line 1: ./android/gradlew: No such file or directory
Is there any way to build apk/aap with Jenkins?
Is it possible to use this plugin? but I already added this one. But not in this my script. https://guides.gradle.org/executing-gradle-builds-on-jenkins/
gradlew or gradlew.bat is an executable of Gradle that can be used to execute gradle commands.
gradlew or gradlew.bat uses gradle/wrapper/gradle-wrapper.jar file for execution.
So there are 3 files in play:
gradlew for mac and linux
gradlew.bat for windows
gradle/wrapper/gradle-wrapper.jar
The thing here is, these files already exists when you create your flutter project. But these files are ignored by .gitignore of the project by default. so these files won't be available in your CI/CD server.
METHOD 1 [RECOMMENDED]
You don't need them to build your project when it is a flutter project. You need flutter SDK to be installed. You can use flutter SDK to build your project. Use following command for release build [you might need to set flutter SDK for your Jenkins server]:
flutter build apk --release
It will run assembleRelease internally and will generate your APK file.
METHOD 2 [NOT RECOMMENDED]
If you want to do it your way then you can add those 3 files to version control by removing their references from .gitignore file and push it to your repository. Then you'll have those file in your Jenkins workspace. You'll have to grant execution permissions to gradlew if you are on mac or linux which can be done by following command.
chmod +x ./gradlew
then you can use following command to build your app:
./gradlew clean assembleRelease
NOTICE: Method 2 is not recommended because when you run flutter commands, it sets some properties to gradle from pubspec.yaml file like version name, version code. So if you made changes to pubspec.yaml file and haven't run flutter command after that, then running gradlew directly won't include those changes. In this case, your apk might built with older version or might not even built as it reads version info from local.properties file which is auto-modified by flutter commands and it is excluded by default from version control. So, you'll also have to add local.properties file by removing its reference from .gitignore file which is very very dirty because it has location reference of android SDK and your server might not have android SDK on that location. Again you need to tackle that. so don't use this method.
You should not do that "on Jenkins". You should do that in your codebase. Execute the wrapper command (gradle wrapper), add wrapper files to Git, commit and push.
In X-Code project of react native, getting error
config.h file not found.
Here is version detail :
react-native-cli: 2.0.1
react-native: 0.51.0
How to solve it?
Close Xcode.
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
Open Xcode and try to run your app.
I had the same issue, using this steps solves for me:
Running into the same issue here after upgrading from 0.44. None of the above solutions or clearing caches did the trick for me. Here's what I did to get things working again:
In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder, run sh ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find
Run your iOS BUILD
Regards!
When project files get messed up for me. I typically follow these steps.
rm -rf node_modules
npm install
react-native upgrade (Only changing affected files, so IOS for you)
react-native link
npm start --reset-cache
(In another terminal)
react-native run-ios
These steps worked for me:
rm -rf ~/.rncache
rm -rf node_modules/
npm install
npm start
You need to change to the legacy build system in Xcode 10 and install third party scripts manually.
1:
File -> Project/Workspace settings
Build System: dropdown -> change to Legacy Build system
2: Follow this to manually install third party scripts for RN:
Clean RN cache
$ rm -rf ~/.rncache
Re-install the deps
$ cd your_project_path
$ rm -rf node_modules/ && npm install
Then install the third-party
$ cd node_modules/react-native/scripts
$ ./ios-install-third-party.sh
Run the commands below if glog installation failed.
$ cd ../third-party/glog-0.3.x
$ ./configure
It works for me, I hope it helps for you.
If above all answers don't work,
Please check that there is no space in any directory name of the full path and not only the project directory name.
While in terminal, it accepts throgh My Disk as My\ Disk but xcode do not recognize that.
If its in My Disk directory, try after moving it to Desktop or any other directory which doesn't have space in their name.
configure: error: unsafe absolute working directory name Issue:
-Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.5/
Run the configure script:
./configure
got error: configure: error: unsafe absolute working directory name
try to created app in desktop and from there run ./configure command.
Please note with XCOXE 10, and Mojave MAC OS , I had same issue, ./configure was showing some permission issue, I had set permission "777" to project folder enclosing with inner folders
This is the linking issue in xcode. You just need to re-link the files.
Please follow the below steps:
Open you peoject's root directory then open node-module -> react-native -> React.
Open React.xcodeproj file in xcode.
You will see missing (showing red in color) files under the third-party folder
Just run the React.xcodeproj project.
After completion close this project & open you project file.
Delete Drive data & Clean the project & run.
If after running the project you are getting linking issue then please make sure you have added all the (ios) products () come under the Libraries -> React.xcodeproj -> Products in your Build Phases -> Link Binary With Libraries.
If everyone has tried solving the issue by this
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
But still not got the solution then,
Go to your Xcode and check if there any library is missing. Add that library and then perform this above step.
Although the already mentioned answers are correct but still few guys are struggling, as only configuring the glog doesn't sometimes resolve the error.
Here I have written a detailed solution to the problem.
Solution: config.h file not found mutex.h During Archive.
The steps are the following:
Remove node_modules directory
Clear Cache
Install packages again with Yarn
Install third party
Configure Glog
Make & Make install glog
For all these above steps the I have shared commands in the above mentioned article, so not going to write again. I hope it will solve problem for guys who are still struggling.
I have a ASP.Net 4.5 MVC application which uses Angular 1.5. The JS code is Typescript and a post build action builds the js code and deploys it to the folder where my application refers to.
I have a Slot on my azure web app which is backed my gitlab repo. Committing to the repo, triggers the deployment, however the post deployment build frequently seems to have issues when a bower/npm or typings library is updated (which is resolved by manually clearing the folder via the kudu console). Does someone have an example of a deploy.cmd script which does the equivalent of
npm install
typings install
at the correct point in the pipeline so that the files get deployed correctly.
I want to start scratch with a new slot, and to get the existing slot to work in the past i had to manually install typings for example "npm install typings --global" in order to get the build to work without a typings error.
Update Output Below
I'm guessing that the errors below are due to azure running typescript 1.6 compiler over reference files which need typescript > 1.6.
My csproj has <TypeScriptToolsVersion>2.0</TypeScriptToolsVersion>
(ive removed my files from the compile output, but the _all.d.ts file does reference the errored files below
CompileTypeScript:
D:\Program Files (x86)\Microsoft SDKs\TypeScript\1.6\tsc.exe --sourcemap --target ES5 --noEmitOnError "REMOVED MY TYPESCRIPTFILES" "D:\home\site\repository\mymvcproject\app\src\_all.d.ts"
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,32): error TS1110: Build: Type expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,50): error TS1005: Build: ']' expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,58): error TS1005: Build: ',' expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,59): error TS1136: Build: Property assignment expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1941,1): error TS1128: Build: Declaration or statement expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
Done Building Project "D:\home\site\repository\mymvcproject\mymvcproject.csproj" (Build;pipelinePreDeployCopyAllFilesToOneFolder target(s)) -- FAILED.
FINAL UPDATE
After the typescript team finally generated a version of typescript 2.* which could be installed on Azure, and then the Kudu team deployed it. Now the whole process works! the note from below about using
"preinstall": "npm install typescript -g && npm install typings -g"
Was the other part of the solution!
According to your requirement, you could follow the steps below to achieve your purpose.
Create a deployment script
You could log in to KUDU tool (https://.scm.azurewebsites.net/), click "Tool" > "Download deployment script". Also, you could leverage azure-cli to generate the script. For more details about how to generate deployment script via azure-cli, you could refer to this tutorial.
Customize the deployment script
For using NPM to manage your packages, you could add the following scripts in your package.json file.
"scripts":{
"preinstall": "npm install typescript -g && npm install typings -g"
}
Then, you need to add the following scripts to the deploy.cmd file.
IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
pushd "%DEPLOYMENT_SOURCE%"
echo installing npm package
call :ExecuteCmd npm install --production
IF !ERRORLEVEL! NEQ 0 goto error
popd
)
Or you could add the following scripts to install typescript and typings directly via command line.
echo Installing typescript and typings
call npm install typescript -g && npm install typings -g
IF !ERRORLEVEL! NEQ 0 goto error
Note: The .deployment, deploy.cmd files need to be placed in the root directory of your solution. You could refer to this sample project for details.
I'm building an angular2 app, and I've developed a build profile in TFS to auto-build it.
There are four npm commands:
npm install angular-cli -g
npm install
npm run typings (executes typings install)
npm run build (executes ng build)
And then a Copy Publish Artifact step.
However, even when every step passes, it says Finishing Copy and Publish Build Artifacts, the project has been built, and the files have been moved, the actual build never finishes. I've tried breaking those npm commands into a powershell script, having them as NPM commands within TFS, and running them as CMD commands, but the same thing happens every time. Also, if I just remote into the build server and run the commands by hand, it works just fine.
Any ideas?
We've gone through the same headache recently, and I'd strongly suggest you not rely on TFS Build to restore npm packages. Even when you get that right, it takes long and doesn't deploy the node_modules you need to IIS.
Instead, use WebPack to bundle up your node_modules into a bundle.js.
Reference this in your projects/scripts folder and check it into source control.
Remove any npm install steps in your build process (it won't be required anymore since you're referencing the bundle.js now).
This will increase your quality (no future package version surprises), and speed up your deployment (no need to download npm packages on each build anymore).
It's fairly quick to get Webpack installed and you'll save yourself headaches :)