React native plugin error - ':react-native-reanimated:compileDebugJavaWithJavac' - react-native

I started seeing this issue last week:
https://github.com/software-mansion/react-native-reanimated/issues/3743
Version used for reanimated
"react-native-reanimated": "^2.12.0",
added in babel.config.js
'react-native-reanimated/plugin',
Below is the steps i added : android/build.gradle
allprojects {
repositories { /* ... */ }
configurations.all {
resolutionStrategy {
force 'com.facebook.react:react-native:0.64.2' // In my case i have react native : 0.64.2
}
}
}
But i am still getting below error:
Task :react-native-reanimated:compileDebugJavaWithJavac FAILED

Related

I am creating expo project with react-native-webrtc, but I got the build error DSO error and after No static method createEGl14

I have issue in build.gradle first i got DSO error tht i solved by using custom plugin and added into app.json but after that I got another error like No static method createEGl14 so I updated the minSdkVersion = 24 but that lead me to the again DSO problem.
//build.gradle
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
// minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
minSdkVersion = 24
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
if (System.properties['os.arch'] == 'aarch64') {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = '24.0.8215888'
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = '21.4.7075529'
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.2.1')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('de.undercouch:gradle-download-task:5.0.1')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup 'com.facebook.react'
}
}
maven { url 'https://www.jitpack.io' }
}
}
//custome plugin to solve DSO issue.
const {
createRunOncePlugin,
withAppBuildGradle,
} = require("#expo/config-plugins");
const withAppBuildGradleModified = (config) => {
return withAppBuildGradle(config, async (file) => {
const modResults = file.modResults;
modResults.contents =
modResults.contents +
"\nandroid.packagingOptions.jniLibs.useLegacyPackaging = true\n";
return file;
});
};
module.exports = createRunOncePlugin(
withAppBuildGradleModified,
"withAppBuildGradleModified",
"1.0.0"
);
//app.json
{
"expo": {
"name": "videocall_webrtc",
"slug": "videocall_webrtc",
"version": "1.0.0",
"assetBundlePatterns": ["**/*"],
"plugins": ["./plugin.js", "#config-plugins/react-native-webrtc"]
}
}
Could you please help me how to resolve this issue. I am using JDK 11 and not using EAS build it is an Bare expo project. Could you please share any example or anything that could help me. Thank you in advance.

Missing plugin in `eas build` of react-native project

I am in the process of trying to build a preview Android version using EAS build, but when I run eas build -p android --profile android-preview I get this error:
[stderr] A problem occurred evaluating project ':unimodules-core'.
[stderr] >
[stderr] Plugin with id 'maven' not found.
Now I see people are suggesting replacing this:
apply plugin: 'maven'
With this, in the build.gradle file:
apply plugin: 'maven-publish'
But I don't find that reference to maven anywhere in my project. And my build.gradle file looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
kotlinVersion: '1.6.20'
if (System.properties['os.arch'] == 'aarch64') {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = '24.0.8215888'
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = '21.4.7075529'
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.2.1')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('de.undercouch:gradle-download-task:5.0.1')
classpath('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup 'com.facebook.react'
}
}
maven { url 'https://www.jitpack.io' }
}
}
How can I resolve this? Any help would be appreciated.

Kotlin with gradle build system cant add JRAW compile "net.dean.jraw:JRAW:1.1.0"

I am all new to Kotlin and gradle and wanted to create a reddit scraper app for fun.
Cant get the guide from this page to work.
https://mattbdean.gitbooks.io/jraw/content/quickstart.html
The guide tells me to put this in the gradle file:
repositories {
jcenter()
}
dependencies {
compile "net.dean.jraw:JRAW:$jrawVersion"
}
But when i put that in my buid.gardle.kts file the ide reports an error
See image below of where the error occurs. The error message is Unexpected tokens.
Found the answer to my question, simply had to add in the variable in the gradle file...
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
var jrawVersion = "1.1.0" //needed to add this in obviously
plugins {
kotlin("jvm") version "1.4.21"
application
}
group = "me.jeppe"
version = "1.0"
repositories {
mavenCentral()
jcenter()
}
dependencies {
testImplementation(kotlin("test-junit"))
compile ("net.dean.jraw:JRAW:$jrawVersion")
}
tasks.test {
useJUnit()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClassName = "MainKt"
}

generating apk in react-native

I am trying to generate my first .apk and facing error from past few days.
I search ans on stack overflow and github to but nothing helped.By instructions here i am able to build debug release but when when run gradlew assembleRelease i am getting errors
E:\p1\placementScript\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigationstack_dist_views_assets_backicon.png:
error: uncompiled PNG file passed as argument. Must be compiled first
into .flat file.. error: failed parsing overlays.
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:processReleaseResources'.
Failed to process resources, see aapt output above for details.
package.json
{
....
"dependencies": {
"babel-preset-es2015": "^6.24.1",
"react": "^16.4.1",
"react-native": "^0.55.4",
"react-native-fcm": "^16.2.3",
"react-native-firebase": "^5.0.0",
"react-native-push-notification": "^3.1.1",
"react-native-view-shot": "^2.4.0",
"react-navigation": "^2.12.1"
}
....
}
and android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "26.0.3"
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
and android/app/build.gradle
...
defaultConfig {
...
}
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
}
}
}
splits {
...
Any other file you want me to upload please ask.
PS:- I have lot of .png files in my src folder (where all .js/etc files are) and do i need to specify some where that they are my assets
It's a fairly common problem. Check out this thread in the RN issues with potential solutions:
https://github.com/facebook/react-native/issues/19211
A solution that worked for me was to
Add the following code to file node_modules/react-native/react.gradle :
doLast {
def moveFunc = { resSuffix ->
File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
if (originalDir.exists()) {
File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
ant.move(file: originalDir, tofile: destDir)
}
}
moveFunc.curry("ldpi").call()
moveFunc.curry("mdpi").call()
moveFunc.curry("hdpi").call()
moveFunc.curry("xhdpi").call()
moveFunc.curry("xxhdpi").call()
moveFunc.curry("xxxhdpi").call()
}
inside def currentBundleTask = tasks.create(...

com.android.ide.common.process.ProcessException: Failed to execute aapt ERROR

I am getting an error like this 'com.android.ide.common.process.ProcessException: Failed to execute aapt' The only thing that I have done is yarn android. Is there any way to solve it in ReactNative ?
Below changes worked for me
In your android/build.gradle make 2 changes after
allprojects {}
New changes
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
}
}
}
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}