Volley - NoClassDefFoundError - android

I have already referred to other answers like this, but still getting the following exception :
E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/volley/toolbox/Volley;
Here are the dependencies :
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.gms:play-services-base:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation "com.google.firebase:firebase-messaging:15.0.0"
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.android.volley:volley:1.1.0'
apply plugin: 'maven'
}
As a matter of fact, when I try adding Volley as a dependency, it is never shown in the list of dependencies. Whereas other google libraries are displayed.
Note : I have already checked other StackOverFlow links, so please, only if you are absolute sure that an answer is correctly working for this, feel free to mark this a duplicate.

Open Command prompt and redirect to your project directory and type this
If you are a Windows user: gradlew.bat clean
if you are a mac user type: ./gradlew clean

If your targetSdkVersion is between 26 and 28, try adding uses-library android:name="org.apache.http.legacy" android:required="false" in application tag in AndroidManifest. The second approach is: import volley.jar into your app/lids directory and instead of fetching it from gradle, use your local jar as implementation files('libs/volley.jar') in build.gradle in app module

Related

react-native-google-signin and android.support.v4.net does not exist error

I have some problem when integrating react-native-google-signin into native android code. I use react-native 0.59.8 and i can't upgrade to 0.60 so far. Therefore I followed an instruction for older react-native-google-signin version which is 2.1.1. Unfortunately it's not working for me. It gives me some errors concerning androidX but as far as I know react-native-google-signin started using androidX from version 3.0.0 upwards, but i use 2.1.1 version which should not use androidX.
Description
The problem starts in sync proccess in Android Studio which gives me the following error:
ERROR: Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
Now when I'm trying to build my project in Android Studio it gives me another error:
error: package android.support.v4.net does not exist
Interesingly, now problem concerns the package #react-native-community/netinfo which was working fine before I linked react-native-google-signin into my project. I would be very grateful if someone told me what's going on.
EDIT:
My dependencies section from android/app/build.gradle is as follows:
dependencies {
implementation project(':react-native-google-signin')
implementation project(':react-native-reanimated')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-firebase')
implementation project(':react-native-community-netinfo')
implementation project(':react-native-orientation')
implementation project(':react-native-keychain')
implementation project(':react-native-view-shot')
implementation project(':react-native-video')
implementation project(':react-native-fs')
implementation project(':react-native-blur')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.facebook.react:react-native:+'
implementation 'com.android.support:design:27.1.1'
implementation project(':react-native-navigation')
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-messaging:17.5.0"
}
Please try the following:
Open your /android/app/build.gradle File, and check your dependencies.
Search for any instance of play-services of firebase, and see for two things:
the line starts with implements (instead of compile)
see if there are any get latest Version wildcard (that is the +-Sign) on it. (Example: implementation "com.google.android.gms:play-services-base:+"
(If you don't found any component implemented with +-Sign, go on further down from topic "GO-ON-HERE" ⇓ in this answer.)
Get those (in my example it is com.google.android.gms:play-services-base and search for it on MVNRepository to get an overview of available Versions.
Here you might choose the newest one, or one that definitely work with your used components and force your App to use it, by updating /android/app/build.gradle like this:
implementation ("com.google.android.gms:play-services-base:17.1.0"){ force = true }
(Note: I don't know, if it's play-services-base in your case, it's only an example)
⇒ GO-ON-HERE
After that, switch to /android and run ./gradlew :app:dependencies. This regenerate your dependency-tree for your Project.
Open the created Text-file and search for your updated Component:com.google.android.gms:play-services-base to see, where the component will be used.
You might find, that still some components use the +-Sign (com.google.android.gms:play-services-base:+) in the dependency. To fix your issue, you need to patch them (maybe use patch-package to simplify this process) to also use the Version for your component (in our example "play-services-base") you've choosed above.
Hope that helps you out.

Error occurring during compile time : error:program type already present: com.google.android.gms.measurement.appmeasurementinstallreferrerreceiver

I've been using Firebase messaging and databases for my project. Using different dependencies and and their specific versions, the program synced completely and there was no gradle build errors.
After connecting the debugging device and trying to install the apk, the error comes as following.
error:program type already present:
com.google.android.gms.measurement.appmeasurementinstallreferrerreceiver
I am unable to proceed further and would really like a solution.I tried surfing the web but am unable to find one.
Not quite sure whats causing the problem,but the gradle dependencies are the ones causing this error. Modifying my build.gradle file as follows
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: "CordovaLib"))
implementation "com.android.support:customtabs:26.+"
implementation "com.android.support:support-v4:24.1.1+"
implementation "com.google.gms:google-services:+"
implementation "com.google.android.gms:play-services-tagmanager:11.0.4"
implementation "com.google.firebase:firebase-core:11.0.4"
implementation "com.google.firebase:firebase-messaging:11.0.4"
implementation "com.google.firebase:firebase-crash:11.0.4"
implementation "com.google.firebase:firebase-config:11.0.4"
implementation "com.google.firebase:firebase-perf:11.0.4"
implementation "com.google.android.gms:play-services-auth:11.0.4"
implementation "com.google.android.gms:play-services-identity:11.0.4"
implementation "com.android.support:appcompat-v7:23+"
// SUB-PROJECT DEPENDENCIES END
}
solved that error for me

Android: Program type already present: com.google.zxing.BarcodeFormat

I've develop a project using zxing to scan the barcode. I had followed the tutorial from here, but unfortunately I got error when I tried to run the project to device. The error that I get is
This is the build.gradle(app)
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// volley
compile 'com.android.volley:volley:1.0.0'
// butter knife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// picasso
implementation 'com.squareup.picasso:picasso:2.71828'
// QR Zxing Library
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
}
Below is External Libraries list.
After a day I tried to find out the solution, but everything failed. Then I decided to create a new project and copy the current source code together with build.gradle(app). Luckily no more error occurred when I run new project.
But I still don't know what the actual reason why I got that error before this, so I assume maybe some part of the old project are missing or have some bug on it.
Because at new project you change buildToolVersion
Reason : Its happened because being conflict between core.jar and zxing
Solution : Just change buildToolVersion and build , after that revert old toolVersion and build again !
After weeks of searching, the following steps help me resolve the issue like a charm:
1.Remove android platform.
2.Install cordova-plugin-facebook4
3.Create build.gradle in /plugins/cordova-plugin-facebook4/
4.Copy this
dependencies {
compile("com.facebook.android:facebook-android-sdk:4.37.0") {
exclude group: 'com.google.zxing'
}
}
to ../plugins/cordova-plugin-facebook4/build.gradle
5.Edit ../plugins/cordova-plugin-facebook4/plugins.xml change
to
6.Add platform android and build

Failed resolving dependencies due to OneSignal

I found the following question: Failed to resolve: com.android.support:customtabs:[26.0.0,26.1.0]
People marked it as duplicate (which is wrong ! see next sentence) or wrote something about Maven or cleaning project etc.
I have exactly the same problem for two days (failed to resolve customtabs and support-v4) and I did not change anything in my project which has been previously working. So I started looking for possible solutions and I found the problem - it is the OneSignal dependency - when I remove it, everything works fine. But I have already implemented notifications in my app - and don't know what to do now. I tried to compile the newest one (mentioned on OneSignal page)
compile 'com.onesignal:OneSignal:[3.6.0,3.99.99)'
But the result is same. Can anyone help?
UPDATE:
The problem can be very easy reproduced - please create a simple project and add this dependency mentioned below (it is from official OneSignal website https://documentation.onesignal.com/v3.0/docs/android-sdk-setup):
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
UPDATE 2:
These are my dependencies:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
compile 'com.android.support:design:25.3.1'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
Adding
maven {
url "https://maven.google.com"
}
to the build.gradle solved the problem with OneSignal, but now I have a problem with Firebase:
java.lang.NoSuchMethodError: No static method zzdD(Ljava/lang/String;)Z in class Lcom/google/android/gms/common/util/zzv; or its super classes (declaration of 'com.google.android.gms.common.util.zzv'
The error happens because you have some conflicted library in your dependency.
As in the documentation, it says:
Automatic Dependencies
OneSignal automatically adds the following dependencies;
com.google.android.gms - Version 11
com.android.support - Version 26
Please makes sure your project matches these versions if you run into
a mismatch version error.
For more details see the All gms/firesbase libraries must use the
exact same version specification section.
So, you need to remove or use the same dependencies in your project, something like this:
compile 'com.android.support:appcompat-v7:26.0.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:11.0.+'
compile 'com.google.firebase:firebase-database:11.0.+'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
compile 'com.android.support:design:26.0.+'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
Remove 'f' from dependency. also, use [ brackets instead of ). its a typo.
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}
and this code in your root gradle file
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

Android Firebase Email and password authentication does not work

I am trying to create accounts in an Android app using Firebase. When I add the following dependencies in the app build.grade file -
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.google.firebase:firebase-auth:10.0.0'//added also tried 10.0.1
testCompile 'junit:junit:4.12'
}
I get the following cryptic build error (btw I'm not using any Twitter SDKs or anything to the best of my knowledge):
Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0
When I change the dependecies to:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebaseui:firebase-ui:0.6.2'//changed
compile 'com.google.firebase:firebase-auth:9.8.0'//changed
testCompile 'junit:junit:4.12'
}
the app build and compiles fine, but when I try to create the account, I get the following error:
Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
I am at a loss as to what I should do because I think I'm using the latest version of the Firebase SDK.
Some more information is that I have used both mFirebaseRef.createUser() and mAuth.createUserWithEmailAndPassword with no success.
I used this link to change the dependencies.
Any help will be deeply appreciated.
You are mixing the legacy SDK:
compile 'com.firebase:firebase-client-android:2.5.2'
with the new SDK:
compile 'com.google.firebase:firebase-auth:10.0.0'
This will cause a number of problems and is the reason for this error message:
Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
For new development, you should use only the new SDK. Delete this line from your dependencies:
compile 'com.firebase:firebase-client-android:2.5.2'
The latest versions of FirebaseAuth require additional repositories. Make this change to your project (top-level) build.gradle file:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
mavenLocal()
}
}
The change is excerpted from the Firebase Sample project. It will eliminate this error:
Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0
you should use the correct firebase authentication version from Google:
compile 'com.google.firebase:firebase-auth:10.0.1'
And you have to setup Firebase as it is described in the official documentation

Categories

Resources