react-native link adds compile to gradle script, but compile support soon gone - react-native

Whenever I use react-native link, it adds the following to my app gradle file.
Image from Android Studio Gradle File
Then when I compile this, Android Studio tells me that "compile" is being deprecated and won't be supported after 2018. My question is, what would the correct replacement be for, for instance, react-native-ionicons?
The section of the gradle file in question is as follows.
dependencies {
compile project(':react-native-vector-icons')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.facebook.react:react-native:+'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.squareup.okhttp3:okhttp:3.4.0-RC1'
implementation 'com.android.support.constraint:constraint-layout:1.0.0-alpha3'
testImplementation 'junit:junit:4.12'}

It was due to react-native link not having been updated but as of React-Native 0.58.3 the linking procedure has been updated so that compile and api have been replaced with implementation. Which you can see at this pull request
You could also just change compile to implementation in your grade file.
However you may find that some of the build.gradle files for the dependencies still use compile and api, unfortunately they only way to fix warnings from those is to make a pull request on the dependency changing compile and api to implementation

Related

FrescoModule tried to override com.facebook.react.modules.fresco.FrescoModule

After upgrading from React-Native 0.59.10 to 0.62.2 I receive this error when running the Android app, the IOS app runs without any issues. I found out Fresco is connected to Flipper but I do not understand how to fix this.
In my MainApplication.java file I have no reference to Flipper or Freso (I tried checking this file for duplicate imports. The only reference to Flipper I have in mainapplication.java is the initializeFlipper part on the bottom of the file (as instructed in the upgrade manual).
Unfortunately because I have no understanding where this is coming from I really have no clue of to which code snippets to include to help solve this error message. If anyone could help me with this, and telling what files/code is relevant here please do!
EDIT: Below is the android/app/build.grade file
dependencies {
implementation project(':react-native-fbsdk')
implementation project(':react-native-firebase')
implementation project(':react-native-google-signin')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-maps')
implementation project(':react-native-screens')
implementation project(':react-native-reanimated')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.facebook.android:facebook-core:5.0.0'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
It's an auto-linking issue make sure to unlink any package that uses fresco
for reference default android/app/build.gradle

Android lint AnnotationProcessorOnCompilePath with ButterKnife

After upgrading to latest Android gradle plugin:
classpath 'com.android.tools.build:gradle:3.6.1'
Android lint (./gradlew lint) getting following warning:
Warning: Add annotation processor to processor path using annotationProcessor instead of implementation [AnnotationProcessorOnCompilePath]
implementation 'com.jakewharton:butterknife:10.2.1'
My app/build.gradle file:
dependencies {
[...]
implementation 'com.jakewharton:butterknife:10.2.1'
kapt 'com.jakewharton:butterknife-compiler:10.2.1'
}
Which is correct according to ButterKnife documentation: https://github.com/JakeWharton/butterknife#download
Hacky solution would be to suppress //noinspection AnnotationProcessorOnCompilePath for ButterKnife.
But how to fix this problem properly?
Apparently, it's a bug on Lint side. They say it will be fixed on the upcoming 4.0 release.
Source:
https://issuetracker.google.com/issues/140881211

React Native command line 'processDebugGoogleServices' error

I am trying to build an app with below build.gradle file but there is always one error failed to create folder. I have checked many answers but no one helped me in this.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Failed to create folder: D:\App\android\app\build\generated\res\google-services\debug
my app/build.gradle file
dependencies {
compile project(':react-native-android-permissions')
compile project(':react-native-push-notification')
compile project(':react-native-fbsdk')
compile project(':react-native-google-signin')
compile project(':react-native-image-resizer')
compile project(':react-native-image-picker')
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile project(':react-native-maps')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':RNPermissionsModule')
compile(project(":react-native-google-signin")) {
exclude group: "com.google.android.gms"
}
compile(project(':react-native-fbsdk')){
exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
}
compile "com.facebook.android:facebook-android-sdk:4.22.1"
compile "com.google.android.gms:play-services-maps:11.8.0"
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:25.0.1"
compile project(':react-native-push-notification')
compile ('com.google.android.gms:play-services-gcm:11.8.0') {
force = true;
}
}
apply plugin: 'com.google.gms.google-services'
Have you used google services plugin in classpath also?
If not please write in build.gradle located outside of the app folder
classpath 'com.google.gms:google-services:3.0.0'
I think this will help you ..!!
I faced the same problem and I solved this by uninstalling the app [yourapp.apk] from your device (e.g: your mobile device) and then run react-native run-android again and it worked like a charm.
But Why?
because you've already had the app with the same name installed on your device (mainly because of the reason that you've downloaded it from somewhere -- and now you want to run the test.app which has the same name, so that's why you've faced this error
do not hesitate to ask me any questions if it didn't work for you!

How to install Evernote android-job on React Native?

I've created a repo in which the error can be easily reproducible:
https://github.com/yaronlevi/android_job_with_react_native
I am trying to install Evernote's library android-job for scheduling jobs in a React Native project (with Play Services also installed).
When I run the project I get an error in the Dex phase:
Multiple dex files define Landroid/support/v4/app/BundleUtil
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/BundleUtil;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/BundleUtil;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
It seems like several libraries are trying to fetch different versions of a support library.
What I did is just added android-job to the gradle file:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.evernote:android-job:1.2.2'
}
The exact steps I took can be seen in the repo link above. (You can clone it and run easily).
How can I solve the conflict that occurs regarding the support library.
Thanks in advance (-:

Error:Unable to resolve version for dependency 'org.jetbrains.kotlin:kotlin-stdlib-jre7:jar'

I have a project written in java I am integrating kotlin with using gradle. I am trying to follow https://kotlinlang.org/docs/reference/using-gradle.html
My build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin"
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7"
}
according to Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7 the library is only available in kotlin v1.1 and up. When I deploy this library and use it in my android project I get the error in the title.
you need to replace
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7"
with
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
Starting with Kotlin 1.1.2 and if you're targeting JDK 7 or JDK 8, you can use extended versions of the Kotlin standard library which contain additional extension functions for APIs added in new JDK versions.
Use one of the following dependencies:
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"