Closed ydv0121 closed 5 years ago
We are automatically closing this issue because it does not appear to follow any of the provided issue templates.
👉 Click here if you want to report a reproducible bug or regression in React Native.
+1 I'm also facing this issue. and none of the solutions working so far.
Here is my package.json
"dependencies": { "apisauce": "1.0.2", "lodash": "4.17.11", "moment": "2.24.0", "react": "16.8.3", "react-native": "0.59.9", "react-native-device-info": "1.5.1", "react-native-fast-image": "5.3.0", "react-native-firebase": "5.3.1", "react-native-iap": "2.5.5", "react-native-image-crop-picker": "0.24.1", "react-native-keyboard-aware-scroll-view": "0.8.0", "react-native-local-mongodb": "2.2.9", "react-native-localization": "2.1.1", "react-native-pdf": "5.1.0", "react-native-router-flux": "4.0.6", "react-native-share": "1.2.1", "react-native-simple-encryption": "1.2.1", "react-native-splash-screen": "3.2.0", "react-native-vector-icons": "6.4.2", "react-native-webview": "5.8.1", "react-redux": "7.0.2", "redux": "4.0.1", "redux-logger": "3.0.6", "redux-thunk": "2.3.0", "rn-fetch-blob": "0.10.15" },
Project build.gradle
`buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" } repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' classpath 'com.google.gms:google-services:4.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
allprojects { repositories { mavenLocal() google() jcenter() maven { url "https://jitpack.io" } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } }`
App build.gradle
`apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [ entryFile: "index.js" ]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false
android { compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.educationwalkthrough"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 3
versionName "1.0"
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('EDU_RELEASE_STORE_FILE')) {
storeFile file(EDU_RELEASE_STORE_FILE)
storePassword EDU_RELEASE_STORE_PASSWORD
keyAlias EDU_RELEASE_KEY_ALIAS
keyPassword EDU_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
debug {
matchingFallbacks = ['release', 'debug']
}
release {
matchingFallbacks = ['release', 'debug']
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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:
// 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
}
}
}
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
dependencies { implementation project(':react-native-share') implementation project(':react-native-pdf') implementation project(':rn-fetch-blob') implementation project(':react-native-iap') implementation project(':react-native-image-crop-picker') implementation project(':react-native-firebase') implementation project(':react-native-splash-screen') implementation project(':react-native-webview') implementation project(':react-native-vector-icons') implementation project(':react-native-localization') implementation project(':react-native-fast-image') implementation project(':react-native-device-info') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.facebook.react:react-native:+" // From node_modules
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.8"
// implementation "com.google.firebase:firebase-auth:17.0.0"
}
// 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 plugin: 'com.google.gms.google-services'`
+1!!! desperate!
+1 ... I have the same issue, what is the solution ?
+1 same issue
+1 same issue today...
I had same issue
Issue is something related to androidX , and I have lots of libraries in my package.json so I am not able to find which library causing issue.
So I decided to update all libraries to latest version, and yet issue is fixed for me
.
make sure you delete node_modules and install again after upgrading then ./gradlew clean and delete build folder in android after
my current package json is below
Hope this helps !
+1 ... I have the same issue, what is the solution ?
+1...same issue here
+1......facing same issue
FIXED
I had same issue
Issue is something related to androidX , and I have lots of libraries in my package.json so I am not able to find which library causing issue.
So I decided to update all libraries to latest version, and yet issue is fixed for me
.
make sure you delete node_modules and install again after upgrading then ./gradlew clean and delete build folder in android after
my current package json is below
Hope this helps !
@BhavanPatel did this but same issue i got..remove ^ from all my package.json and npm reinstall..
+1...... same issue today
FIXED
I had same issue
Issue is something related to androidX , and I have lots of libraries in my package.json so I am not able to find which library causing issue.
So I decided to update all libraries to latest version, and yet issue is fixed for me
.
make sure you delete node_modules and install again after upgrading then ./gradlew clean and delete build folder in android after
my current package json is below
Hope this helps !
@BhavanPatel this solution not work =D
+1 ... SAME ISSUE!!!
@ydv0121
*FIXED
I had same issue Issue is something related to androidX , and I have lots of libraries in my package.json so I am not able to find which library causing issue. So I decided to update all libraries to latest version, and yet issue is fixed for me . make sure you delete node_modules and install again after upgrading then ./gradlew clean and delete build folder in android after my current package json is below Hope this helps !
@BhavanPatel did this but same issue i got..remove ^ from all my package.json and npm reinstall..
U need to upgrade all libs to latest version, not only removing ^
either you can manually put it in package json and reinstall or can be done with
npm i <package-name>@latest --save
cd android && ./gradlew app:dependencies
Set Google Play Services to specific version number (check https://developers.google.com/android/guides/releases for the version you want to use):
implementation "com.google.android.gms:play-services-maps:16.0.0"
If a package uses a newer version (see 1.) of the Google Play Services libraries, just exclude it in your app's build.gradle
:
implementation(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
Add attributes to <application>
in your AndroidManifest.xml
:
android:appComponentFactory="androidx"
tools:replace="android:appComponentFactory"
Add config to settings.gradle
:
android.useAndroidX=false
android.enableJetifier=false
I'm not too sure about 4. and 5. but it's working for me like this. Be sure to revert this stuff when you update to 0.60+ and AndroidX support is provided by all libraries you use.
As mentioned by @firehand33 it could be that you have to force the Google Play Services libraries versions, e.g.:
implementation ("com.google.android.gms:play-services-gcm:16.1.0") {
force = true
}
@ddthuan87 what steps u have followed?
@ddthuan87 what steps u have followed?
i'm clear gradlew -> delete all node_module -> npm_install -> it still shows the old error
@ddthuan87 U need to upgrade packages to latest just cleaning and reinstalling wont work
@ddthuan87 U need to upgrade packages to latest just cleaning and reinstalling wont work
thk, i will try this again :D
- Check if you have a library which depends on AndroidX:
cd android && ./gradlew app:dependencies
- For me it was Google Play Services @ 18.0.0 which depends on AndroidX.
- Set Google Play Services to specific version number (check https://developers.google.com/android/guides/releases for the version you want to use):
implementation "com.google.android.gms:play-services-maps:16.0.0"
- If a package uses a newer version (see 1.) of the Google Play Services libraries, just exclude it in your app's
build.gradle
:implementation(project(':react-native-maps')) { exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-maps' }
- Add attributes to
<application>
in yourAndroidManifest.xml
:android:appComponentFactory="androidx" tools:replace="android:appComponentFactory"
- Add config to
settings.gradle
:android.useAndroidX=false android.enableJetifier=false
I'm not too sure about 4. and 5. but it's working for me like this. Be sure to revert this stuff when you update to 0.60+ and AndroidX support is provided by all libraries you use.
Now it show me another error:
Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Program type already present: androidx.versionedparcelable.ParcelImpl
FAILURE: Build failed with an exception.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.versionedparcelable.ParcelImpl
- Check if you have a library which depends on AndroidX:
cd android && ./gradlew app:dependencies
- For me it was Google Play Services @ 18.0.0 which depends on AndroidX.
- Set Google Play Services to specific version number (check https://developers.google.com/android/guides/releases for the version you want to use):
implementation "com.google.android.gms:play-services-maps:16.0.0"
- If a package uses a newer version (see 1.) of the Google Play Services libraries, just exclude it in your app's
build.gradle
:implementation(project(':react-native-maps')) { exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-maps' }
- Add attributes to
<application>
in yourAndroidManifest.xml
:android:appComponentFactory="androidx" tools:replace="android:appComponentFactory"
- Add config to
settings.gradle
:android.useAndroidX=false android.enableJetifier=false
I'm not too sure about 4. and 5. but it's working for me like this. Be sure to revert this stuff when you update to 0.60+ and AndroidX support is provided by all libraries you use.
Now it show me another error:
Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Program type already present: androidx.versionedparcelable.ParcelImpl
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.versionedparcelable.ParcelImpl
+1
Now it show me another error:
Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Program type already present: androidx.versionedparcelable.ParcelImpl
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.versionedparcelable.ParcelImpl
Please check again with cd android && ./gradlew app:dependencies
if there really are no AndroidX dependencies left.
Now it show me another error:
Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Program type already present: androidx.versionedparcelable.ParcelImpl
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.versionedparcelable.ParcelImpl
Please check again with
cd android && ./gradlew app:dependencies
if there really are no AndroidX dependencies left.
I did follow your steps, and run ./gradlew app:dependencies but no help bro :(. I think it causes my libraries...
@percyphan86 try my steps if it works
Now it show me another error:
Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Program type already present: androidx.versionedparcelable.ParcelImpl
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.versionedparcelable.ParcelImpl
Please check again with
cd android && ./gradlew app:dependencies
if there really are no AndroidX dependencies left.
tried this..and androidX is within the com.google.android.gms:play-services-base:16.1.0 -> 17.0.0
here is my dependencies
`dependencies { compile project(':react-native-google-places') compile project(':react-native-app-tour') compile project(':react-native-androw') compile project(':react-native-svg') compile project(':react-native-vector-icons') implementation project(':tipsi-stripe') implementation project(':react-native-maps') implementation project(':react-native-linear-gradient') implementation project(':react-native-image-crop-picker') //implementation project(':react-native-image-base64') implementation project(':react-native-i18n') implementation project(':react-native-google-signin') compile 'com.intellij:annotations:+@jar' implementation project(':react-native-firebase') implementation 'com.facebook.android:facebook-android-sdk:4.34.0' implementation project(':react-native-fbsdk') implementation project(':react-native-device-info') implementation project(':react-native-contacts') implementation project(':react-native-google-places') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.android.support:multidex:1.0.3' implementation 'com.google.android.gms:play-services-base:16.1.0' implementation 'com.google.android.gms:play-services-places:+' implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'com.google.android.gms:play-services-gcm:16.1.0' implementation 'com.google.android.gms:play-services-maps:16.1.0' implementation "com.google.firebase:firebase-core:16.0.1" implementation "com.google.firebase:firebase-messaging:17.1.0" implementation 'com.google.android.gms:play-services-measurement-base:+' implementation 'com.google.firebase:firebase-analytics:+' implementation "com.android.support:support-v4:28.0.0" //implementation 'com.android.support:support-annotations:28.0.0' implementation 'com.android.support:support-annotations:+' implementation 'com.android.support:support-compat:+' implementation "com.android.support:support-media-compat:28.0.0"
}`
@ydv0121 what's the line above the one in the screenshot?
@ydv0121 what's the line above the one in the screenshot?
@ydv0121 I think all/most of these have to have the same version numbers (check https://developers.google.com/android/guides/releases where this can't be):
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-places:+'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
Try setting all of them to 16.0.0
@ydv0121 I think all/most of these have to have the same version numbers (check https://developers.google.com/android/guides/releases where this can't be):
implementation 'com.google.android.gms:play-services-base:16.1.0' implementation 'com.google.android.gms:play-services-places:+' implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'com.google.android.gms:play-services-gcm:16.1.0' implementation 'com.google.android.gms:play-services-maps:16.1.0'
Try setting all of them to
16.0.0
did it but can't able to resolve versions
Does anybody know why do I have many androidx dependencies injected as above While these are my dependencies:
dependencies {
implementation project(':react-native-push-notification')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-navigation')
implementation 'com.google.android.gms:play-services-base:16.0.0'
implementation 'com.google.firebase:firebase-messaging:16.0.0'
}
???
1,Check if you have a library which depends on AndroidX: cd android && ./gradlew app:dependencies 2,For me it was com.google.android.gms:play-services-gcm , com.google.android.gms:play-services-vision (in react-native-camera,react-native-device-info) which depends on AndroidX. 3, Use old version of Google Play Services . in your app build.gradle, add this:
subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.google.android.gms' && details.requested.name.contains('play-services-gcm')) { details.useVersion '16.0.0' }
if (details.requested.group == 'com.google.android.gms'
&& details.requested.name.contains('play-services-vision')) {
details.useVersion '15.0.2'
}
}
}
}
i solved mine with these dependencies
implementation project(':react-native-firebase')
implementation(project(':react-native-push-notification')) {
exclude group: 'com.google.android.gms'
}
implementation ("com.google.android.gms:play-services-gcm:16.1.0") {
force = true
}
implementation ("com.google.android.gms:play-services-base:16.1.0") {
force = true
}
implementation ("com.google.firebase:firebase-core:16.0.9") {
force = true
}
implementation ("com.google.firebase:firebase-messaging:18.0.0") {
force = true
}
+1
It seems that the issue resides mainly in the react-native-community dependencies that require Google Play Services, which recently (today) had a new release with breaking changes. For example, for me, the dependency was react-native-device-info, which already has the fix in its new release (2.1.2). So basically, search what node modules require com.google.android.gms and, if a fix version is available (it's not guaranteed), upgrade to that
+1 same issue today...
same issue
This broken changes are coming from the last release of Google Play Services (https://developers.google.com/android/guides/releases).
Running npm update
gives no solution.
If I upgrade to AndroidX like said in the Android docs (https://developer.android.com/jetpack/androidx/migrate) then almost all react-native plugins are broken because they are depend on Android Support library.
So for now how to make project run with old Android Support library, not with AndroidX. I am not Android developer so I am really confused with this.
+1 same issue
This broken changes are coming from the last release of Google Play Services (https://developers.google.com/android/guides/releases).
Running
npm update
gives no solution. If I upgrade to AndroidX like said in the Android docs (https://developer.android.com/jetpack/androidx/migrate) then almost all react-native plugins are broken because they are depend on Android Support library.So for now how to make project run with old Android Support library, not with AndroidX. I am not Android developer so I am really confused with this.
we need to stick with out old version(16) of googleplayservices and updated the dependencies.but still some users have issues
Downgrade Google Play service version. In android/app/build.gradle
change
compile 'com.google.android.gms:play-services-<service_name>:+'
to
compile 'com.google.android.gms:play-services-<service_name>:16.0.0'
So in my case location
. But in someone's else case it may be any other Google Play Service (like in list here http://www.androiddocs.com/google/play-services/setup.html).
+1
you can force google play service version in android> build.gradle
file in ext
like following
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "16.0.0"
googlePlayServicesVisionVersion = "17.0.2"
}
my issue fixed :)
@ydv0121 yes it is fixed you need to add the version which is used in your project
In my case problem was produced by react-native-push-notification
package (https://github.com/zo0r/react-native-push-notification/blob/master/android/build.gradle#L50).
It has com.google.firebase:firebase-messaging
as dependency and it was upgraded from 18.0.0 -> 19.0.0
. What produced adroidx
injection as dependency.
Solution: add firebaseVersion=18.0.0
to your gradle.properties
solved it by updating all third party libraries as per @BhavanPatel said and
add dependencies like this
implementation ('com.google.android.gms:play-services-tasks:16.0.1'){ force = true } implementation ('com.google.android.gms:play-services-base:16.1.0'){ force = true } implementation ('com.google.android.gms:play-services-places:16.1.0'){ force = true } implementation ('com.google.android.gms:play-services-location:16.0.0'){ force = true } implementation ('com.google.android.gms:play-services-gcm:16.1.0'){ force = true } implementation ('com.google.android.gms:play-services-maps:16.1.0'){ force = true } implementation ('com.google.android.gms:play-services-basement:16.2.0'){ force = true }
and also add this in android/build.gradle as per @dilipchandima said
ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" googlePlayServicesVersion = "16.0.0" googlePlayServicesVisionVersion = "17.0.2" }
thank you @BhavanPatel & @dilipchandima mix of some solutions worked for me :D
Same issue, build created but app crashing on start
@ydv0121 Thanks for that list. Those version #s work for me!
got this error today to add the tools:replace in my mainfest
when i add tools:replace="android:appComponentFactory" to my mainfest file got another error -
don't understand how to resolve this?