React Native build error: Text must not be null or empty - react-native
My Jenkins build has given me the following error:
13:18:22 FAILURE: Build failed with an exception.
13:18:22
13:18:22 * Where:
13:18:22 Script '/Users/abcd/Jenkins/Jenkins-Workspaces/ABCD/ABCDL/node_modules/#react-native-community/cli-platform-android/native_modules.gradle' line: 190
13:18:22
13:18:22 * What went wrong:
13:18:22 A problem occurred evaluating settings 'AppName'.
13:18:22 > Text must not be null or empty
13:18:22
It seems the problem is with the #react-native-community/cli-platform node module, but reading over this closed issue:
https://github.com/facebook/react-native/issues/25479
its unclear to me what exactly is the proposed and final solution to this.
There is a recommendation on a fix that is more straightforward in this react-native issue:
https://github.com/facebook/react-native/issues/25822
but my error is not complaining about that line.
As far as installing #react-native-community/cli I believe I already have it inside my package-lock.json file:
"react-native": {
"version": "0.60.4",
"resolved": "https://registry.npmjs.org/react-native/-/react-native-0.60.4.tgz",
"integrity": "sha512-WE41lbGQjnzM9srIFtMDtMJkQAvk95iZwuFvAxl68s80bkYa7Ou9sGFHpeYIV6cY8yHtheCSo5q6YMxhdfkdOw==",
"requires": {
"#babel/runtime": "^7.0.0",
"#react-native-community/cli": "^2.0.1",
"#react-native-community/cli-platform-android": "^2.0.1",
"#react-native-community/cli-platform-ios": "^2.0.1",
Others mentioned something about app/build.gradle, here is the relevant part of mine:
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Mention was also made of android/settings.gradle, this one is mine:
rootProject.name = 'NFIBEngage'
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':appcenter-crashes'
project(':appcenter-crashes').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-crashes/android')
include ':appcenter-analytics'
project(':appcenter-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-analytics/android')
include ':appcenter'
project(':appcenter').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
From what I have gathered here:
https://react-native-community.github.io/upgrade-helper/?from=0.53.3&to=0.60.4
The above files are correct.
So what exactly is wrong here and how do I fix it?
In terms of node_modules/#react-native-community/cli-platform-android/native_modules.gradle line 190 is this one:
def json = new JsonSlurper().parseText(reactNativeConfigOutput)
Could the problem be with how I wrote index.js file:
/**
* #format
*/
import { AppRegistry } from "react-native";
// old config code
import KeyboardManager from "react-native-keyboard-manager";
// old config code ^^^
import NFIBEngage from "./App";
import { name as appName } from "./app.json";
// old config code
import { Sentry } from "react-native-sentry";
Sentry.config(
"https://asdf#sentry.io/123456677"
).install();
KeyboardManager.setToolbarPreviousNextButtonEnable(true);
// old config code ^^^
AppRegistry.registerComponent("NFIBEngage", () => NFIBEngage);
Is AppRegistry.registerComponent() written correctly?
I ran the Jenkins script locally, which I believe is this script right here:
import fs from "fs-extra";
import eachSeries from "async/eachSeries";
import { exec } from "child_process";
import { androidDirectory } from "../../app.json";
import { resolveFromRoot, distDir, createLogger } from "../build";
const logger = createLogger("android");
const APK_PATTERN = /release\.apk$/i;
function copyArtifactsToDist() {
logger.logHeader("Copying APK to Dist", { repeatChar: "=" });
const baseDir = `${androidDirectory}/app/build/outputs/apk`;
const allFlavs = ["dev", "qa", "ua", "prod"];
const branchName = process.env.GitVersion_BranchName || "";
const buildFlavour = branchName.startsWith("release/") ? allFlavs : ["dev"];
const envs = {
dev: "INT",
qa: "QA",
ua: "UA",
prod: ""
};
buildFlavour
.map(env => {
const apkOutputDir = resolveFromRoot(`${baseDir}/${env}/release`);
return {
apkOutputDir,
env
};
})
.forEach(({ apkOutputDir, env }) => {
const src = `${apkOutputDir}/app-${env}-release.apk`;
//prettier-ignore
const binaryName = env === 'prod' ? 'ENGAL.apk' : `ENGAL-${envs[env]}.apk`;
const dest = `${distDir}/${binaryName}`;
fs.copy(src, dest, (err: Error) => {
if (err) {
logger.error(err);
}
});
});
}
function run() {
logger.logHeader("Starting Android Builds", { repeatChar: "#" });
const flavours = [
{
endpoint: "dv",
flavour: "Dev",
appcenterKey: "<hashKeys>"
},
{
endpoint: "qa",
flavour: "Qa",
appcenterKey: "<hashKeys>"
},
{
endpoint: "ua",
flavour: "Ua",
appcenterKey: "<hashKeys>"
},
{
endpoint: "prod",
flavour: "Prod",
appcenterKey: "<hashKeys>"
}
];
const versionCode = process.env.Build || 1;
const release = process.env.GitVersion_MajorMinorPatch || "1.0.0";
const fullAppVersion = `${release}-${versionCode}`;
const devFlav = flavours.find(f => f.flavour.toLocaleLowerCase() === "dev");
const branchName = process.env.GitVersion_BranchName || "";
const buildFlavour = branchName.startsWith("release/") ? flavours : [devFlav];
eachSeries(
buildFlavour,
(f, callback) => {
//prettier-ignore
logger.logHeader(
`starting gradle assemble${f.flavour}Release with flag - versionName=${fullAppVersion} -PversionCode=${versionCode}`,
{repeatChar: '-'}
);
const engaInfo = `ENGAGE_VERSION=${fullAppVersion}`;
const engaEndpoint = `ENGAGE_ENDPOINT=${f.endpoint}`;
const engaCenter = `APPCENTER_KEY=${f.appcenterKey}`;
const engaPlatform = "APPCENTER_PLATFORM=android";
//prettier-ignore
const prepare = `${engaEndpoint} ${engaCenter} ${engaInfo} ${engaPlatform} npm run setup`;
const cd = `cd ${androidDirectory}`;
//prettier-ignore
const releaseCmd = `./gradlew assemble${f.flavour}Release -PversionName=${fullAppVersion} -PversionCode=${versionCode} && cd ..`;
exec(`${prepare} && ${cd} && ${releaseCmd}`, err => {
if (err) {
return callback(err);
}
logger.logHeader(`${f.flavour} Android Build Successful!`, {
repeatChar: "#"
});
logger.close();
callback(null);
});
},
error => {
if (error) {
logger.logHeader("Android Builds Failed!", {
repeatChar: "#"
});
logger.error(error);
logger.close();
}
copyArtifactsToDist();
}
);
}
run();
via npm run build and locally I got this error:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assembleDevRelease' not found in root project 'AppName'. Some candidates are: 'assembleRelease'.
Are these related errors? Anyone experienced with React Native builds?
As suggested, I looked into my android/app/build.gradle file for productFlavors and noticed that indeed they were missing between here:
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 123456 + defaultConfig.versionCode
}
}
}
So I added it like so:
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
productFlavors {
dev {
resValue "string", "app_name", getAppName("INT")
resValue "string", "link_launcher", getLauncher("dv")
applicationIdSuffix ".dv"
manifestPlaceholders = [onesignal_app_id: "<hash_id>",
onesignal_google_project_number: "123456789"]
}
qa {
resValue "string", "app_name", getAppName("QA")
resValue "string", "link_launcher", getLauncher("qa")
applicationIdSuffix ".qa"
manifestPlaceholders = [onesignal_app_id: "<hash_id>",
onesignal_google_project_number: "123456789"]
}
ua {
resValue "string", "app_name", getAppName("UA")
resValue "string", "link_launcher", getLauncher("ua")
applicationIdSuffix ".ua"
manifestPlaceholders = [onesignal_app_id: "<hash_id>",
onesignal_google_project_number: "123456789"]
}
prod {
resValue "string", "app_name", getAppName()
resValue "string", "link_launcher", getLauncher()
manifestPlaceholders = [onesignal_app_id: "<hash_id>",
onesignal_google_project_number: "601125149914"]
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
The buildTypes is looking a bit different than the original legacy buildTypes so I am not sure if that's okay, but at any rate I then ran npm run build again locally and got this error:
* Where:
Build file '/Users/danale/Projects/NFIBEngage/android/app/build.gradle' line: 168
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method getAppName() for arguments [INT] on ProductFlavor_Decorated{name=dev, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.
I was able to resolve the local error by adding the missing methods like so:
def appName = "Engage";
/**
* Get the version name from command line param
*
* #return int If the param -PversionName is present then return int value or -1
*/
def getAppName = { env ->
return (env ? appName + " ("+ env + ")" : appName);
}
/**
* Get the version name from command line param
*
* #return int If the param -PversionName is present then return int value or -1
*/
def getLauncher = { env ->
return (env ? "engage-" + env + ".nfib.org" : "engage.nfib.org");
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "default"
defaultConfig {
applicationId "com.nfib.engage"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
productFlavors {
dev {
dimension 'default'
resValue "string", "app_name", getAppName("INT")
resValue "string", "link_launcher", getLauncher("dv")
applicationIdSuffix ".dv"
manifestPlaceholders = [onesignal_app_id: "b78285eb-f1ec-46f3-9ad0-c7efe691a401",
onesignal_google_project_number: "584236827312"]
}
qa {
dimension 'default'
resValue "string", "app_name", getAppName("QA")
resValue "string", "link_launcher", getLauncher("qa")
applicationIdSuffix ".qa"
manifestPlaceholders = [onesignal_app_id: "e4280f5e-62ec-41a4-bd86-f5b94e471a36",
onesignal_google_project_number: "162802054510"]
}
ua {
dimension 'default'
resValue "string", "app_name", getAppName("UA")
resValue "string", "link_launcher", getLauncher("ua")
applicationIdSuffix ".ua"
manifestPlaceholders = [onesignal_app_id: "2ffd8dc0-9c6b-4035-999d-fc694194725a",
onesignal_google_project_number: "594905904045"]
}
prod {
dimension 'default'
resValue "string", "app_name", getAppName()
resValue "string", "link_launcher", getLauncher()
manifestPlaceholders = [onesignal_app_id: "82dcb42f-1d35-4b79-bc28-2d1d02dbda36",
onesignal_google_project_number: "601125149914"]
}
}
Unfortunately, I continue to get the same error in Jenkins.
Some of the changes to get the build working, from comments:
From your package.json, your cli version is at ^2.0.1 and 2.0.1 is indeed the version of the cli that had the issue you linked to from github.com/facebook/react-native/issues/25479 Have you verified that the line similar to def command = "../node_modules/.bin/react-native config" (from github.com/facebook/react-native/issues/…) in your node_modules/#react-native-community/cli-platform-android/native_modules.gradle is correct? You should also ensure your installed version of the cli is >= 2.0.2.
Make sure your buildTypes and productFlavors definitions in android/app/build.gradle are set up to include all the different variants you are trying to build in your jenkins job. Looks like you have flavors for dev, qa, ua and prod. Check out the gradle docs developer.android.com/studio/build/build-variants#build-types for more info.
Looks like you're missing a getAppName function in your build.gradle. Something like ext.getAppName = {suffix = '' -> 'MyAppName' + suffix}. A quick scan of your build.gradle looks like you need another called getLauncher which returns an appropriate string for whatever you use link_launcher for.
I upgraded my node version on my CI tool and fixed this exact error.
I was previously on version 6 and bumped it to 10
I have also face this problem
very easy solution for this problem
Remove node_module
and
Reinstall node_module : npm install
react-native run-android
Related
node_modules\react-native\react.gradle' line: 286
i am trying to build my app but i am getting error building it errors are: Task :app:bundleReleaseJsAndAssets FAILED FAILURE: Build completed with 2 failures. 1: Task failed with an exception. Where: Script 'C:\Users\Ali Yousafzai\Desktop\ProjectFiver\BluetoothPlanner\node_modules\react-native\react.gradle' line: 286 What went wrong: Execution failed for task ':app:bundleReleaseJsAndAssets'. Process 'command 'cmd'' finished with non-zero exit value 1 2: Task failed with an exception. What went wrong: java.lang.StackOverflowError (no error message) this is my react.gradle file /* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import org.apache.tools.ant.taskdefs.condition.Os import org.gradle.internal.jvm.Jvm def config = project.hasProperty("react") ? project.react : [:]; def detectEntryFile(config) { if (System.getenv('ENTRY_FILE')) { return System.getenv('ENTRY_FILE') } else if (config.entryFile) { return config.entryFile } else if ((new File("${projectDir}/../../index.android.js")).exists()) { return "index.android.js" } return "index.js"; } def composeSourceMapsPath = config.composeSourceMapsPath ?: "node_modules/react-native/scripts/compose-source-maps.js" def bundleAssetName = config.bundleAssetName ?: "index.android.bundle" def entryFile = detectEntryFile(config) def bundleCommand = config.bundleCommand ?: "bundle" def reactRoot = file(config.root ?: "../../") def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"] def bundleConfig = config.bundleConfig ? "${reactRoot}/${config.bundleConfig}" : null ; def enableVmCleanup = config.enableVmCleanup == null ? true : config.enableVmCleanup def hermesCommand = config.hermesCommand /** * Detects CLI location in a similar fashion to the React Native CLI */ def detectCliPath(config, reactRoot) { // 1. preconfigured path if (config.cliPath) { def cliJsAbsolute = new File(config.cliPath) if (cliJsAbsolute.exists()) { return cliJsAbsolute.getAbsolutePath() } def cliJsRelativeToRoot = new File("${rootDir}/${config.cliPath}") if (cliJsRelativeToRoot.exists()) { return cliJsRelativeToRoot.getAbsolutePath() } def cliJsRelativeToProject = new File("${projectDir}/${config.cliPath}") if (cliJsRelativeToProject.exists()) { return cliJsRelativeToProject.getAbsolutePath() } } // 2. node module path def cliJsFromNode = new File(["node", "--print", "require.resolve('react-native/cli').bin"].execute(null, rootDir).text.trim()) if (cliJsFromNode.exists()) { return cliJsFromNode.getAbsolutePath() } // 3. cli.js in the root folder def rootCliJs = new File(reactRoot, "node_modules/react-native/cli.js") if (rootCliJs.exists()) { return rootCliJs.getAbsolutePath() } throw new Exception("Couldn't determine CLI location. " + "Please set `project.ext.react.cliPath` to the path of the react-native cli.js file. " + "This file typically resides in `node_modules/react-native/cli.js`"); } def reactNativeDevServerPort() { def value = project.getProperties().get("reactNativeDevServerPort") return value != null ? value : "8081" } def reactNativeInspectorProxyPort() { def value = project.getProperties().get("reactNativeInspectorProxyPort") return value != null ? value : reactNativeDevServerPort() } def getHermesOSBin() { if (Os.isFamily(Os.FAMILY_WINDOWS)) return "win64-bin"; if (Os.isFamily(Os.FAMILY_MAC)) return "osx-bin"; if (Os.isOs(null, "linux", "amd64", null)) return "linux64-bin"; throw new Exception("OS not recognized. Please set project.ext.react.hermesCommand " + "to the path of a working Hermes compiler."); } // Make sure not to inspect the Hermes config unless we need it, // to avoid breaking any JSC-only setups. def getHermesCommand = { // 1. If the project specifies a Hermes command, don't second guess it. if (config.hermesCommand?.trim()) { if (hermesCommand.contains("%OS-BIN%")) { return hermesCommand .replaceAll("%OS-BIN%", getHermesOSBin()) .replace('/' as char, File.separatorChar) } else { return hermesCommand .replace('/' as char, File.separatorChar) } } def hermescBin = Os.isFamily(Os.FAMILY_WINDOWS) ? 'hermesc.exe' : 'hermesc' // 2. If the project is building hermes-engine from source, use hermesc from there // Also note that user can override the hermes source location with // the `REACT_NATIVE_OVERRIDE_HERMES_DIR` env variable. def hermesOverrideDir = System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR") def builtHermesc = hermesOverrideDir ? new File(hermesOverrideDir, "build/bin/$hermescBin") : new File(reactRoot, "node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/$hermescBin") if (builtHermesc.exists()) { return builtHermesc.getAbsolutePath() } // 3. If the react-native contains a pre-built hermesc, use it. def prebuiltHermesPath = "node_modules/react-native/sdks/hermesc/%OS-BIN%/$hermescBin" .replaceAll("%OS-BIN%", getHermesOSBin()) .replace('/' as char, File.separatorChar); def prebuiltHermes = new File(reactRoot, prebuiltHermesPath) if (prebuiltHermes.exists()) { return prebuiltHermes.getAbsolutePath() } throw new Exception("Couldn't determine Hermesc location. " + "Please set `project.ext.react.hermesCommand` to the path of the hermesc binary file. " + "node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"); } // Set enableHermesForVariant to a function to configure per variant, // or set `enableHermes` to True/False to set all of them def enableHermesForVariant = config.enableHermesForVariant ?: { def variant -> config.enableHermes ?: false } // Set hermesFlagsForVariant to a function to configure per variant, // or set `hermesFlagsRelease` and `hermesFlagsDebug` to an array def hermesFlagsForVariant = config.hermesFlagsForVariant ?: { def variant -> def hermesFlags; if (variant.name.toLowerCase().contains("release")) { // Can't use ?: since that will also substitute valid empty lists hermesFlags = config.hermesFlagsRelease if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"] } else { hermesFlags = config.hermesFlagsDebug if (hermesFlags == null) hermesFlags = [] } return hermesFlags } // Set disableDevForVariant to a function to configure per variant, // defaults to `devDisabledIn${targetName}` or True for Release variants and False for debug variants def disableDevForVariant = config.disableDevForVariant ?: { def variant -> config."devDisabledIn${variant.name.capitalize()}" || variant.name.toLowerCase().contains("release") } // Set bundleForVariant to a function to configure per variant, // defaults to `bundleIn${targetName}` or True for Release variants and False for debug variants def bundleForVariant = config.bundleForVariant ?: { def variant -> config."bundleIn${variant.name.capitalize()}" || config."bundleIn${variant.buildType.name.capitalize()}" || variant.name.toLowerCase().contains("release") } // Set deleteDebugFilesForVariant to a function to configure per variant, // defaults to True for Release variants and False for debug variants def deleteDebugFilesForVariant = config.deleteDebugFilesForVariant ?: { def variant -> variant.name.toLowerCase().contains("release") } android { buildTypes.all { resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort() resValue "integer", "react_native_inspector_proxy_port", reactNativeInspectorProxyPort() } } def jvmVersion = Jvm.current().javaVersion.majorVersion if (jvmVersion.toInteger() <= 8) { println "\n\n\n" println "**************************************************************************************************************" println "\n\n" println "ERROR: requires JDK11 or higher." println "Incompatible major version detected: '" + jvmVersion + "'" println "\n\n" println "**************************************************************************************************************" println "\n\n\n" System.exit(1) } afterEvaluate { def isAndroidLibrary = plugins.hasPlugin("com.android.library") def variants = isAndroidLibrary ? android.libraryVariants : android.applicationVariants variants.all { def variant -> // Create variant and target names def targetName = variant.name.capitalize() def targetPath = variant.dirName // React js bundle directories def jsBundleDir = file("$buildDir/generated/assets/react/${targetPath}") def resourcesDir = file("$buildDir/generated/res/react/${targetPath}") def jsBundleFile = file("$jsBundleDir/$bundleAssetName") def jsSourceMapsDir = file("$buildDir/generated/sourcemaps/react/${targetPath}") def jsIntermediateSourceMapsDir = file("$buildDir/intermediates/sourcemaps/react/${targetPath}") def jsPackagerSourceMapFile = file("$jsIntermediateSourceMapsDir/${bundleAssetName}.packager.map") def jsCompilerSourceMapFile = file("$jsIntermediateSourceMapsDir/${bundleAssetName}.compiler.map") def jsOutputSourceMapFile = file("$jsSourceMapsDir/${bundleAssetName}.map") // Additional node and packager commandline arguments def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"] def cliPath = detectCliPath(config, reactRoot) def execCommand = [] if (Os.isFamily(Os.FAMILY_WINDOWS)) { execCommand.addAll(["cmd", "/c", *nodeExecutableAndArgs, cliPath]) } else { execCommand.addAll([*nodeExecutableAndArgs, cliPath]) } def enableHermes = enableHermesForVariant(variant) def currentBundleTask = tasks.create( name: "bundle${targetName}JsAndAssets", type: Exec) { group = "react" description = "bundle JS and assets for ${targetName}." // Create dirs if they are not there (e.g. the "clean" task just ran) doFirst { jsBundleDir.deleteDir() jsBundleDir.mkdirs() resourcesDir.deleteDir() resourcesDir.mkdirs() jsIntermediateSourceMapsDir.deleteDir() jsIntermediateSourceMapsDir.mkdirs() jsSourceMapsDir.deleteDir() jsSourceMapsDir.mkdirs() } // Set up inputs and outputs so gradle can cache the result inputs.files fileTree(dir: reactRoot, excludes: inputExcludes) outputs.dir(jsBundleDir) outputs.dir(resourcesDir) // Set up the call to the react-native cli workingDir(reactRoot) // Set up dev mode def devEnabled = !disableDevForVariant(variant) def extraArgs = [] if (bundleConfig) { extraArgs.add("--config") extraArgs.add(bundleConfig) } // Hermes doesn't require JS minification. if (enableHermes && !devEnabled) { extraArgs.add("--minify") extraArgs.add("false") } if (config.extraPackagerArgs) { extraArgs.addAll(config.extraPackagerArgs) } commandLine(*execCommand, bundleCommand, "--platform", "android", "--dev", "${devEnabled}", "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, "--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs) if (enableHermes) { doLast { def hermesFlags = hermesFlagsForVariant(variant) def hbcTempFile = file("${jsBundleFile}.hbc") exec { if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine("cmd", "/c", getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags) } else { commandLine(getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags) } } ant.move( file: hbcTempFile, toFile: jsBundleFile ); if (hermesFlags.contains("-output-source-map")) { ant.move( // Hermes will generate a source map with this exact name file: "${jsBundleFile}.hbc.map", tofile: jsCompilerSourceMapFile ); exec { // TODO: set task dependencies for caching // Set up the call to the compose-source-maps script workingDir(reactRoot) if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine("cmd", "/c", *nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile) } else { commandLine(*nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile) } } } } } enabled bundleForVariant(variant) } // Expose a minimal interface on the application variant and the task itself: variant.ext.bundleJsAndAssets = currentBundleTask currentBundleTask.ext.generatedResFolders = files(resourcesDir).builtBy(currentBundleTask) currentBundleTask.ext.generatedAssetsFolders = files(jsBundleDir).builtBy(currentBundleTask) // registerGeneratedResFolders for Android plugin 3.x if (variant.respondsTo("registerGeneratedResFolders")) { variant.registerGeneratedResFolders(currentBundleTask.generatedResFolders) } else { variant.registerResGeneratingTask(currentBundleTask) } variant.mergeResourcesProvider.get().dependsOn(currentBundleTask) // packageApplication for Android plugin 3.x def packageTask = variant.hasProperty("packageApplication") ? variant.packageApplicationProvider.get() : tasks.findByName("package${targetName}") if (variant.hasProperty("packageLibrary")) { packageTask = variant.packageLibrary } // pre bundle build task for Android plugin 3.2+ def buildPreBundleTask = tasks.findByName("build${targetName}PreBundle") def resourcesDirConfigValue = config."resourcesDir${targetName}" if (resourcesDirConfigValue) { def currentCopyResTask = tasks.create( name: "copy${targetName}BundledResources", type: Copy) { group = "react" description = "copy bundled resources into custom location for ${targetName}." from(resourcesDir) into(file(resourcesDirConfigValue)) dependsOn(currentBundleTask) enabled(currentBundleTask.enabled) } packageTask.dependsOn(currentCopyResTask) if (buildPreBundleTask != null) { buildPreBundleTask.dependsOn(currentCopyResTask) } } def currentAssetsCopyTask = tasks.create( name: "copy${targetName}BundledJs", type: Copy) { group = "react" description = "copy bundled JS into ${targetName}." from(jsBundleDir) if (config."jsBundleDir${targetName}") { into(file(config."jsBundleDir${targetName}")) } else { into ("$buildDir/intermediates") if (isAndroidLibrary) { into ("library_assets/${variant.name}/out") } else { into ("assets/${targetPath}") // Workaround for Android Gradle Plugin 3.2+ new asset directory into ("merged_assets/${variant.name}/merge${targetName}Assets/out") // Workaround for Android Gradle Plugin 3.4+ new asset directory into ("merged_assets/${variant.name}/out") // Workaround for Android Gradle Plugin 7.1 asset directory into("$buildDir/intermediates/assets/${variant.name}/merge${targetName}Assets") } } // mergeAssets must run first, as it clears the intermediates directory dependsOn(variant.mergeAssetsProvider.get()) enabled(currentBundleTask.enabled) dependsOn(currentBundleTask) } // mergeResources task runs before the bundle file is copied to the intermediate asset directory from Android plugin 4.1+. // This ensures to copy the bundle file before mergeResources task starts def mergeResourcesTask = tasks.findByName("merge${targetName}Resources") mergeResourcesTask.dependsOn(currentAssetsCopyTask) packageTask.dependsOn(currentAssetsCopyTask) if (buildPreBundleTask != null) { buildPreBundleTask.dependsOn(currentAssetsCopyTask) } // Delete the VM related libraries that this build doesn't need. // The application can manage this manually by setting 'enableVmCleanup: false' // // This should really be done by packaging all Hermes related libs into // two separate HermesDebug and HermesRelease AARs, but until then we'll // kludge it by deleting the .so files out of the /transforms/ directory. def cleanup = deleteDebugFilesForVariant(variant) def vmSelectionAction = { libDir -> fileTree(libDir).matching { if (enableHermes) { // For Hermes, delete all the libjsc* files include "**/libjsc*.so" if (cleanup) { // Reduce size by deleting the debugger/inspector include '**/libhermes-executor-debug.so' } else { // Release libs take precedence and must be removed // to allow debugging include '**/libhermes-executor-release.so' } } else { // For JSC, delete all the libhermes* files include "**/libhermes*.so" } }.visit { details -> def targetVariant1 = ".*/transforms/[^/]*/${variant.name}/.*" def targetVariant2 = ".*/merged_native_libs/${variant.name}/out/lib/.*" def targetVariant3 = ".*/stripped_native_libs/${variant.name}/out/lib/.*" def path = details.file.getAbsolutePath().replace(File.separatorChar, '/' as char) if ((path.matches(targetVariant1) || path.matches(targetVariant2) || path.matches(targetVariant3)) && details.file.isFile()) { details.file.delete() } } } if (enableVmCleanup) { def task = tasks.findByName("package${targetName}") if (task != null) { def transformsLibDir = "$buildDir/intermediates/transforms/" task.doFirst { vmSelectionAction(transformsLibDir) } } def sTask = tasks.findByName("strip${targetName}DebugSymbols") if (sTask != null) { def strippedLibDir = "$buildDir/intermediates/stripped_native_libs/${variant.name}/out/lib/" sTask.doLast { vmSelectionAction(strippedLibDir) } } def mTask = tasks.findByName("merge${targetName}NativeLibs") if (mTask != null) { def mergedLibDir = "$buildDir/intermediates/merged_native_libs/${variant.name}/out/lib/" mTask.doLast { vmSelectionAction(mergedLibDir) } } } } } // Patch needed for https://github.com/facebook/react-native/issues/35210 // This is a patch to short-circuit the "+" dependencies inside the // users' app/build.gradle file and the various .gradle files of libraries. // As using plain "+" dependencies causes Gradle to always download the latest, // this logic forces Gradle to use latest release in the minor series. project.rootProject.allprojects { configurations.all { resolutionStrategy { force "com.facebook.react:react-native:0.70.+" force "com.facebook.react:hermes-engine:0.70.+" } } }
I was in the same situation, the problem is when you have a space in the directory path. This only happens on Windows + Hermes + folders that have a space in the path For more details check this post A quick fix is to remove the space from the path C:\Users\Ali Yousafzai\ -> C:\Users\AliYousafzai\ or Just zip your project and move the file to a folder with no space C:\yourproject
Kotlin lowercase Function
I am new to kotlin, so I am sorry in advance, if this is a simple misstake. I am trying at the moment to rewrite an api (written in Kotlin) to java 17. Everything worked so far. But now I am getting following deprecated message: 'toLowerCase(): String' is deprecated. Use lowercase() instead. Of course I know what it means, so I tried doing it like in the following Picture: https://i.stack.imgur.com/vT8k5.png But why doesnt it find the lowercase Function? This is in my build.gradle: plugins { id 'org.jetbrains.kotlin.jvm' id "org.jetbrains.kotlin.kapt" id "org.jetbrains.dokka" id "java-library" id "maven-publish" id "jacoco" id "io.gitlab.arturbosch.detekt" id "org.jlleitschuh.gradle.ktlint" id "com.github.gmazzo.buildconfig" } apply from: "${rootDir}/gradle/dependencies.gradle" tasks.withType(org.jetbrains.dokka.gradle.DokkaTask).configureEach { dokkaSourceSets { configureEach { sourceLink { localDirectory.set(file("src/main/kotlin")) remoteUrl.set(uri("").toURL()) } externalDocumentationLink { url.set(new URL("https://square.github.io/retrofit/2.x/retrofit/")) } externalDocumentationLink { url.set(new URL("https://square.github.io/okhttp/3.x/okhttp/")) } externalDocumentationLink { url.set(new URL("https://square.github.io/moshi/1.x/moshi/")) } } } } tasks.dokkaJavadoc.configure { outputDirectory.set(javadoc.destinationDir) } task sourceJar(type: Jar) { archiveClassifier = "sources" from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { archiveClassifier = "javadoc" from javadoc.destinationDir } tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { jvmTarget = "17" allWarningsAsErrors = true freeCompilerArgs = ["-Xjsr305=strict", "-progressive"] } } kapt { useBuildCache = true } test { finalizedBy jacocoTestReport useJUnitPlatform() } buildConfig { packageName("my.package") // forces the package. Defaults to '${project.group}' useKotlinOutput() // adds `internal` modifier to all declarations buildConfigField("String", "packageName", "\"my.package\"") buildConfigField("String", "version", provider { "\"${project.version}\"" }) } jacoco { setToolVersion(jacocoVersion) } jacocoTestReport { reports { xml.required = true html.required = false } } ktlint { disabledRules = ["import-ordering"] version = ktlintVersion reporters { reporter "checkstyle" } } detekt { version = detektVersion buildUponDefaultConfig = true config = files("$rootDir/config/detekt.yml") } repositories { mavenCentral() } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" } compileKotlin { kotlinOptions { jvmTarget = "17" } } compileTestKotlin { kotlinOptions { jvmTarget = "17" } }
Ensure your kotlin-stdlib version is 1.5 or above. Check this out
Can not ready file text within build.gradle.kts
I am trying to print a kotlin class before compiling it to generate another class. I tried many methods to be sure about printing the file text before compiling it through File.readText() but nothings success-ed always printing code joined with symbols as the following screenshot. My Gradle code tasks.findByName("compileKotlin") ?.dependsOn(tasks.register("compileKotlin2") { doFirst { var names2 = "filesPath= " fileTree("$buildDir\\classes\\kotlin\\main\\tech\\example\\ecommerce\\ecommerce\\controller\\") .visit { if (this.file.name != "WebPagesController.class") { names2 += this.file.path + "\n" println(file(this.file.path).readText()) } } println(names2) } }) Full build.gradle.kts import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("plugin.jpa") version "1.3.61" id("org.springframework.boot") version "2.2.5.RELEASE" id("io.spring.dependency-management") version "1.0.9.RELEASE" kotlin("jvm") version "1.3.61" kotlin("plugin.spring") version "1.3.61" } group = "tech.example.ecommerce" version = "0.0.1-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_1_8 repositories { mavenCentral() } dependencies { // springframework implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("org.springframework.boot:spring-boot-starter-mail") implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("mysql:mysql-connector-java") // kotlin implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") // testing testImplementation("org.springframework.boot:spring-boot-starter-test") { exclude(group = "org.junit.vintage", module = "junit-vintage-engine") } } tasks.findByName("compileKotlin") ?.dependsOn(tasks.register("compileKotlin2") { doFirst { println("hiiiiiiiii") var names2 = "a= " fileTree("$buildDir\\classes\\kotlin\\main\\tech\\example\\ecommerce\\ecommerce\\controller\\") .visit { if (this.file.name != "WebPagesController.class") { names2 += this.file.path + "\n" println(file(this.file.path).readText()) } } println(names2) } }) tasks.withType<Test> { useJUnitPlatform() } tasks.withType<KotlinCompile> { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") jvmTarget = "1.8" } } Any hints are welcomed, Thanks in advance
In fileTree("$buildDir\\classes\\kotlin\\main\\tech\\example\\ecommerce\\ecommerce\\controller\\") using projectDir instead of buildDir with syntax fileTree("$projectDir/src/main/kotlin/tech/example/ecommerce/ecommerce/controller") s
TypeError: undefined is not an object (evaluating 'o.NetInfo.isConnected')
I have a trouble with launching my app.. Tried everything that I found in similar topics, but still no success :( I use: Android Studio 3.5.3 Gradle Version 6 react-native-cli: 2.0.1 react-native: 0.61.5 I successfully migrated to Androidx using jetifier (I hope so) #react-native-community/netinfo version is 5.5.0 build.grandle: buildscript { repositories { google() jcenter() maven { url("$rootDir/../node_modules/jsc-android/dist") } maven { url 'https://maven.fabric.io/public' } maven { url "https://repo.gradle.org/gradle/repo" } mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.google.gms:google-services:4.3.3' classpath 'org.codehaus.groovy:groovy-all:2.4.15' classpath 'io.fabric.tools:gradle:1.28.1' } } allprojects { repositories { mavenLocal() maven { url ("$rootDir/../node_modules/react-native/android") } maven { url("$rootDir/../node_modules/jsc-android/dist") } maven { url "https://jitpack.io" } maven { url "https://maven.google.com" } google() jcenter() } } ext { compileSdkVersion = 28 targetSdkVersion = 28 minSdkVersion = 16 buildToolsVersion = "29.0.3" //androidXCore = "1.0.2" supportLibVersion="28.0.0" googlePlayServicesVersion = "15.0.1" googlePlayServicesVisionVersion = "17.0.2" androidMapsUtilsVersion = "0.5+" } subprojects { subproject -> afterEvaluate{ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) { android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion } } } subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'androidx.core' && !details.requested.name.contains('androidx')) { details.useVersion "1.0.0" } if (details.requested.group == 'androidx.core' && !details.requested.name.contains('multidex') ) { details.useVersion "28.+" } if (details.requested.group == 'com.google.android.gms' && !details.requested.name.contains('multidex') && !details.requested.name.contains('play-services-stats')) { details.useVersion "12.+" } if (details.requested.group == 'com.google.android.gms' && !details.requested.name.contains('multidex') && details.requested.name.contains('play-services-stats')) { details.useVersion "+" } } } } } settings.gradle rootProject.name = 'modelalliance_client' include ':react-native-reanimated' project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android') include ':react-native-image-crop-picker' project(':react-native-image-crop-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-crop-picker/android') include ':react-native-share' project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android') include ':react-native-fetch-blob' project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android') include ':react-native-camera' project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android') include ':rn-fetch-blob' project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-touch-id' project(':react-native-touch-id').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-touch-id/android') include ':react-native-pdf' project(':react-native-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf/android') include ':react-native-maps' project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android') include ':react-native-linear-gradient' project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android') include ':react-native-document-picker' project(':react-native-document-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-picker/android') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') include ':react-native-image-resizer' project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android') include ':react-native-image-picker' project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android') include ':react-native-gesture-handler' project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android') include ':react-native-firebase' project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android') include ':#react-native-community-netinfo' project(':#react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/#react-native-community/netinfo/android') include ':app' app/build.gradle apply plugin: "com.android.application" import com.android.build.OutputFile def useIntlJsc = false project.ext.react = [ entryFile: "index.js", jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/out", enableHermes: true, hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes", bundleInStaging: true, // Add this bundleInInternalTest: true, // Add this bundleInRelease: true ] apply from: "../../node_modules/react-native/react.gradle" def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false def jscFlavor = 'org.webkit:android-jsc:+' def enableHermes = project.ext.react.get("enableHermes", false) android { compileSdkVersion 28 buildToolsVersion '29.0.3' packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' exclude 'META-INF/ASL2.0' exclude 'META-INF/INDEX.LIST' exclude("META-INF/*.kotlin_module") } defaultConfig { applicationId "com.modelalliance_client" minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { // abiFilters "armeabi-v7a", "x86" } missingDimensionStrategy 'react-native-camera', 'general' } packagingOptions { pickFirst '**/armeabi-v7a/libc++_shared.so' pickFirst '**/x86/libc++_shared.so' pickFirst '**/arm64-v8a/libc++_shared.so' pickFirst '**/x86_64/libc++_shared.so' pickFirst '**/x86/libjsc.so' pickFirst '**/armeabi-v7a/libjsc.so' } signingConfigs { release { if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) { storeFile file(MYAPP_RELEASE_STORE_FILE) storePassword MYAPP_RELEASE_STORE_PASSWORD keyAlias MYAPP_RELEASE_KEY_ALIAS keyPassword MYAPP_RELEASE_KEY_PASSWORD } } } project.ext.sentryCli = [ logLevel: "debug", flavorAware: false, //add enableHermes: false ] compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } splits { abi { reset() enable true universalApk false // If true, also generate a universal APK include "armeabi-v7a","arm64-v8a","x86","x86_64" exclude "ldpi", "xxhdpi", "xxxhdpi" } } buildTypes { release { minifyEnabled enableProguardInReleaseBuilds shrinkResources enableSeparateBuildPerCPUArchitecture proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" signingConfig signingConfigs.release } debug{ minifyEnabled enableProguardInReleaseBuilds shrinkResources enableSeparateBuildPerCPUArchitecture proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" signingConfig signingConfigs.release } all {minifyEnabled enableProguardInReleaseBuilds shrinkResources enableSeparateBuildPerCPUArchitecture proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" signingConfig signingConfigs.release} } applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a":3,"x86_64":4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1' implementation project(':react-native-reanimated') implementation 'org.codehaus.groovy:groovy-all:2.4.15' testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' if (useIntlJsc) { implementation 'org.webkit:android-jsc-intl:+' } else { implementation 'org.webkit:android-jsc:+' } implementation 'com.google.android.gms:play-services-auth:17.0.0' implementation project(':react-native-image-crop-picker') implementation project(':react-native-share') implementation project(':rn-fetch-blob') implementation project(':react-native-fs') implementation project(':react-native-image-resizer') implementation project(':react-native-image-picker') implementation project(':react-native-touch-id') implementation project(':react-native-linear-gradient') implementation project(':react-native-pdf') implementation project(':react-native-vector-icons') implementation project(':react-native-document-picker') implementation project(':react-native-gesture-handler') implementation project(':react-native-firebase') implementation project(':#react-native-community-netinfo') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.github.dhaval2404:imagepicker-support:1.5' implementation 'androidx.arch.core:core-runtime:2.1.0' implementation 'androidx.arch.core:core-common:2.1.0' implementation "org.webkit:android-jsc:r241213" implementation 'androidx.appcompat:appcompat:1.2.0-alpha02' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03' implementation "com.google.firebase:firebase-storage:19.1.1" implementation "com.google.firebase:firebase-database:19.2.1" implementation "com.google.firebase:firebase-dynamic-links:19.0.0" implementation "com.google.firebase:firebase-invites:17.0.0" implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.core:core:1.1.0' implementation "com.facebook.react:react-native:0.61.5" // From node_modules implementation(project(':react-native-camera')) { exclude group: 'com.google.android.gms' implementation ('com.google.android.gms:play-services-vision:15.0.1') { force = true } } implementation('com.google.android.gms:play-services-vision:19.0.0') compile(project(':react-native-maps')){ exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-maps' } implementation 'com.google.android.gms:play-services-base:17.1.0' implementation 'com.google.android.gms:play-services-maps:17.0.0' implementation "com.google.android.gms:play-services-gcm:17.0.0" implementation 'com.google.firebase:firebase-messaging:20.1.0' implementation 'com.google.firebase:firebase-firestore:21.4.0' implementation "com.google.firebase:firebase-database:19.2.1" implementation 'com.google.guava:guava:27.0.1-android' implementation 'androidx.leanback:leanback:1.1.0-alpha03' compile('com.google.guava:guava-jdk5:17.0') { force = true } implementation 'org.gradle:gradle-core:2.2.1' implementation(project(':react-native-camera')) { exclude group: "com.google.android.gms" compile ('com.google.android.gms:play-services-vision:15.0.1') { force = true } } implementation 'androidx.annotation:annotation:1.1.0' if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/" debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } implementation 'com.google.android.gms:play-services-base:17.1.0' implementation 'com.google.android.gms:play-services-analytics:17.0.0' implementation 'com.google.android.gms:play-services-awareness:18.0.0' implementation 'com.google.android.gms:play-services-cast:18.0.0' implementation 'com.google.android.gms:play-services-gcm:17.0.0' implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'com.google.android.gms:play-services-maps:17.0.0' implementation 'com.google.firebase:firebase-core:17.2.2' implementation 'com.google.firebase:firebase-iid:20.0.2' implementation 'com.google.firebase:firebase-messaging:20.1.0' implementation 'android.arch.work:work-runtime:1.0.1' implementation 'com.android.support:multidex:1.0.3' apply plugin: 'com.google.gms.google-services' } configurations { all*.exclude group: 'com.google.guava', module:'guava-jdk5' } task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } gradle.properties: android.useAndroidX=true android.enableJetifier=true android.useDeprecatedNdk=true MYAPP_RELEASE_STORE_FILE=divo.keystore MYAPP_RELEASE_KEY_ALIAS=my-key-alias MYAPP_RELEASE_STORE_PASSWORD=Glaz5756523 MYAPP_RELEASE_KEY_PASSWORD=Glaz5756523 org.gradle.jvmargs=-Xmx4608m android.jetifier.blacklist = your-troublemaker-library.jar
error when import kotlin project android studio 3.5.3
I try to import project i get this error when import project in android studio 3.5.3 Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified and this error This version of Android Studio cannot open this project, please retry with Android Studio 3.6 or newer import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.application") kotlin("android") kotlin("kapt") } // https://stackoverflow.com/a/52441962 fun String.runCommand( workingDir: File = File("."), timeoutAmount: Long = 60, timeoutUnit: TimeUnit = TimeUnit.SECONDS ): String? = try { ProcessBuilder("\\s".toRegex().split(this)) .directory(workingDir) .redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.PIPE) .start().apply { waitFor(timeoutAmount, timeoutUnit) } .inputStream.bufferedReader().readText() } catch (e: java.io.IOException) { e.printStackTrace() null } android { compileSdkVersion(29) buildToolsVersion("29.0.2") viewBinding.isEnabled = true val gitVersion = listOf( "git rev-parse --abbrev-ref HEAD", "git rev-list HEAD --count", "git rev-parse --short HEAD" ).joinToString("-") { it.runCommand()?.trim() ?: "" } + (if (("git status -s".runCommand() ?: "").isBlank()) "" else "-dirty") defaultConfig { applicationId = "com.test.cale" minSdkVersion(15) targetSdkVersion(29) versionCode = 621 versionName = "6.2.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true resConfigs("en", "fa", "ckb", "ar", "ur", "ps", "glk", "azb", "ja") setProperty("archivesBaseName", "PersianCalendar-$versionName-$gitVersion") } signingConfigs { create("nightly") { storeFile = rootProject.file("nightly.keystore") storePassword = "android" keyAlias = "androiddebugkey" keyPassword = "android" } } buildTypes { create("nightly") { signingConfig = signingConfigs.getByName("nightly") versionNameSuffix = "-${defaultConfig.versionName}-$gitVersion-nightly" applicationIdSuffix = ".nightly" isMinifyEnabled = true isShrinkResources = true } getByName("debug") { versionNameSuffix = "-${defaultConfig.versionName}-$gitVersion" applicationIdSuffix = ".debug" } getByName("release") { isMinifyEnabled = true isShrinkResources = true // Maybe proguard-android-optimize.txt in future // setProguardFiles(listOf(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")) } } } dependencies { implementation(project(":equinox")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${KotlinCompilerVersion.VERSION}") implementation("androidx.appcompat:appcompat:1.1.0") implementation("androidx.preference:preference-ktx:1.1.0") implementation("androidx.recyclerview:recyclerview:1.1.0") implementation("androidx.cardview:cardview:1.0.0") implementation("androidx.viewpager2:viewpager2:1.0.0") implementation("com.google.android.material:material:1.1.0-rc02") implementation("com.google.android:flexbox:1.1.0") implementation("com.google.android.apps.dashclock:dashclock-api:2.0.0") val navVersion = "2.1.0" implementation("androidx.navigation:navigation-fragment-ktx:$navVersion") implementation("androidx.navigation:navigation-ui-ktx:$navVersion") implementation("androidx.core:core-ktx:1.1.0") implementation("androidx.fragment:fragment-ktx:1.1.0") implementation("androidx.activity:activity-ktx:1.0.0") implementation("androidx.browser:browser:1.0.0") implementation("androidx.work:work-runtime-ktx:2.2.0") // debugImplementation("com.squareup.leakcanary:leakcanary-android:2.0-alpha-2") // debugImplementation("com.github.pedrovgs:lynx:1.1.0") testImplementation("junit:junit:4.12") androidTestImplementation("androidx.test:runner:1.2.0") androidTestImplementation("androidx.test:rules:1.2.0") androidTestImplementation("androidx.test.espresso:espresso-contrib:3.2.0") androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") } please resolve the problem
Top-level Project Gradle buildscript { repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.6.0-rc01") classpath(kotlin("gradle-plugin", version = "1.3.61")) } } allprojects { repositories { google() jcenter() maven("https://jitpack.io") } } task("clean") { delete(rootProject.buildDir) }