autolinking.gradle does not exist error when excuting expo run:android - react-native

I'm trying to run my android expo project on android by executing expo run:android
and i'm getting this error
this is my settings.gradle file
rootProject.name = 'K53Learners'
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()
apply from: new File(["node", "--print", "require.resolve('#react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild(new File(["node", "--print", "require.resolve('react-native-gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile())
if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
include(":ReactAndroid")
project(":ReactAndroid").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid");
include(":ReactAndroid:hermes-engine")
project(":ReactAndroid:hermes-engine").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid/hermes-engine");
}

Related

Task :react-native-async-storage_async-storage:generateReleaseRFile FAILED

i got a bug when i build react native apk. last week I built no error. but now an error occurs, even though there is no new package that I installed.
Task :react-native-async-storage_async-storage:generateReleaseRFile FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateReleaseRFile'.
> Could not resolve all files for configuration ':react-native-async-storage_async-storage:releaseCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=release, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/facebook/react/react-native/0.71.0-rc.0/react-native-0.71.0-rc.0-release.aar
i wish i could build apk
hope this can help you [FIXED] Android build failures No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found
in my case it was because of using maven's react native version how I fixed it.
android/build.gradle
mavenCentral()
jcenter()
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central
as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }

react-native metro bundler error: bundling failed: ReferenceError: SHA-1 for file

I am getting the an error when I am using react-native start, the bundler error is:
bundling failed: ReferenceError: SHA-1 for file /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js) is not computed
at DependencyGraph.getSha1 (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:258:13)
at /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:211:26
at Generator.next (<anonymous>)
at asyncGeneratorStep (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:46:24)
at _next (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:66:9)
at /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:71:7
at new Promise (<anonymous>)
at /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:63:12
at Transformer.transformFile (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:236:7)
I am getting this error ever since I have installed the react-native-camera, I don't know if that is the real issue. I have tried doing rm -rf node_modules/ && yarn install && react-native start -- --reset-cache but it didn't work. Here is my top level build.gradle file :
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
classpath("com.google.gms:google-services:4.0.2")
}
}
allprojects {
repositories {
....
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://www.jitpack.io" }
}
}
Here is my app level build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
....
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.firebase:firebase-analytics:17.2.2" // Firebase analytics
implementation 'com.google.firebase:firebase-core:17.0.0'
.....
}
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: "com.google.gms.google-services"
The problem solved by npm uninstall react-native-cli && yarn add global react-native-cli and I removed all node_modules and reinstalled with rm -rf node_modules && yarn install, then it worked.

Android: AIRMap was not found in the UIManager

So i'm trying to implement a map view in my react native app, using react-native-maps. When i'm installing it with npm it's all good, and linking it makes no errors. The problem is when i try to run it, then I get the
Invariant Violation: requireNativeComponent: "AIRMap" was not fount in the UIManager.
I've narrowed it down to being on the Android side, since that's the emulator i'm running. For some reason, the gradle files seems broken and I have no idea of what it can be. I've tried most guides i've found but none seems to handle the issue. I've tried to link it manually, remove the link and so on. I've also tried adding the direct link to GitHub which doesn't solve it either.
Some build info:
React version: 0.60.0
Gradle version: 5.4.1
Emulator version: Pie API 28
settings.gradle:
rootProject.name = 'ProjectName'
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)
include ':app'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
build.gradle:
implementation 'com.facebook.react:react-native:+
implementation project(':react-native-maps')
MapView:
import MapView from 'react-native-maps'
<MapView
region={{
latitude: 42.882004,
longitude: 74.582748,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
></MapView>
Lastly, I have also created an API to Google maps in the android project.
The project is manageable to recreate by initiating a new react-native project and implementing react-native-maps
For Android
AndroidManifest.xml
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzDDDBBLn-PhCtBM1AnC_h66yH8Lw2DDD14WW0"/>
</application>
MainApplication.java
import java.util.List;
import com.airbnb.android.react.maps.MapsPackage; // <-- Add this line
...
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new MapsPackage()); // <- ADD THIS LINE
return packages;
}
android/settings.gradle
if you are not using monorepo technique
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-maps/lib/android')
android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
supportLibVersion = '28.0.0'
playServicesVersion = "17.0.0" // or find latest version
googlePlayServicesVersion = "17.0.0" // or find latest version
androidMapsUtilsVersion = "2.2.3"
}
repositories {
jcenter()
google() // keep google() at last
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../../../node_modules/jsc-android/dist")
}
jcenter()
maven { url 'https://www.jitpack.io' }
google() // keep google() at last
}
}
android/app/build.gradle
dependencies {
...
implementation project(':react-native-maps') // at last
}
Notes
I am using ../../../node_modules because I am using Monorepo technique to maintain 2 apps in one git repo
../node_modules might work for you
keep google() at last of the code-block
IOS
See this for solution in IOS https://stackoverflow.com/a/67945288/3437900

How to fix missing ReactContextBaseJavaModule symbol?

I wan't to create a custom native module for my app only - so no lib. Following the docs it gives me an error:
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Cannot resolve symbol 'ReactContextBaseJavaModule'
My app's android/app/build.gradle includes this line, which is included in all react-native modules I have used so far as well.
"com.facebook.react:react-native:+" // From node_modules
My android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}
}
Below are the steps I encountered and used to solve importing all the libraries related to React Native Libraries in the Android Studio:
First when I created a brand new react native library project using react-native-create-library command, the command generated iOS and Android files.
I opened the android folder using Android Studio.
The gradle build reported some errors and fixed the gradle issue by updating some values in build.gradle and gradle-wrapper.properties.
build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile 'com.facebook.react:react-native:+'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
After adding the above 2 changes, Click Sync Now or Try again. In this step if it asks to install the build version, please install.
Now Clean and Rebuild the project, On top status bar of the Android Studio:
Click Build --> Clean Project then
Click Build --> Rebuild Project
After step #5, React Native import errors should disappear and the libraries related to React Native must be imported.
Thanks.

task 'compileDebug' is ambiguous in root project

I'm compiling my project for distribution and I've gotten an error.
Here's the error:
Error:Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_73\bin\java.exe'' finished with non-zero exit value 2
I've gone in and gotten the stacktrace-* Try:
Run gradlew tasks to get a list of available tasks. Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in root project 'Inspirerr_Final'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTestJavaWithJavac', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources'.
at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:101)
at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:76)
at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42)
at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:44)
at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:42)
at org.gradle.execution.DefaultBuildExecuter.access$100(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:48)
at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47)
at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:42)
at org.gradle.execution.DefaultBuildExecuter.access$100(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:48)
at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44)
at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:42)
at org.gradle.execution.DefaultBuildExecuter.select(DefaultBuildExecuter.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
BUILD FAILED
And my gradle file
:apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.volley:volley:1.0.0'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build- types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Any help you can offer would be greatly appreciated. Thank you!
Maybe.there are such code in your BuildConfig,
// Fields from build type: debug
public static final boolean ENABLE_DEVELOP_MODE = true;
And you use it in some place.
When you build release, it will dismiss and build failed.