i back to work again to complete my application but when the application start syncing it gave me
Failed to resolve: androidx Affected Modules: href="openFile:D:/.android/Step View/Application/Source Code/app/build.gradle">app
I see a question like this but it didn't works for me. sorry for my bad english.
this is my gradle. app
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven {
url 'https://maven.google.com'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xcoder.stepview"
minSdkVersion 17
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.connection_light.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '6a2c7692-81ec-4d12-b973-6b78f71f380e',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.kittinunf.fuel:fuel-android:1.12.1'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.github.bassaer:chatmessageview:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'com.github.markushi:circlebutton:1.1'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'commons-io:commons-io:2.5'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.connection_light:runner:1.1.1'
androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
In my case it was caused by a typo in build.gradle:
//androidTestImplementation 'androidx .test.espresso:espresso-core:3.2.0' // wrong!
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
I found the error by running the Gradle wrapper from the command line with the stacktrace option:
./gradlew clean build --stacktrace
Output:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException:
Could not find androidx. test.espresso:espresso-core:3.2.0.
Try to update all com.android* to the available com.androidx* versions that you can.
Make sure you have...
android.enableJetifier=true
android.useAndroidX=true
Added to your gradle.properties.
Or you could just do
With Android Studio 3.2 and higher, you can quickly migrate an existing project
to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
https://developer.android.com/jetpack/androidx/migrate
You are using both support library and androidx library in one project, that's the issue.
Change the support libraries to the preferred AndroidX library.
and also you can Migrate to AndroidX from Android Studio itself
Simply go to Refactor > Migrate to AndroidX > Migrate
add below code in gradle.properties file
android.enableJetifier=true
android.useAndroidX=true
more info for migration check this
for me it was
implementation 'androidx.appcompat:appcompat:1.1.0'
which must be
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
that means check versions and implement the last ones for each androidx you have.
you most upgrade all base library
change it
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
to
implementation 'androidx.appcompat:appcompat:1.+'
and
androidTestImplementation 'androidx.connection_light:runner:1.1.1'
to
androidTestImplementation 'androidx.test:runner:1.+'
and
androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'
to
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Related
I was trying to learn how to use OkHTTP. I importetd the library to my project but when i compile the code it brings out this error.
Could not find org.junit.jupiter:junit-jupiter:.
Required by:
project :app
Search in build.gradle files.
please what should i do. This is my build.gradle below
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.omolayoseun.saprktesterapp"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-
rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
}
junit-jupiter dependency is used only for running junit 5 Unit tests, in your case you don't even need this dependency. Feel free to delete it. And make sure you run the project by selecting app in the run menu.
Once you decide to run actual unit tests use these dependencies:
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
Seems that your problem is in the maven repository setting.
Place the code below to your build.gradle which is located in the project core folder.
buildscript {
repositories {
mavenCentral()
google()
}}
If it not helps or this repositories already there - try to turn off offline mode.
Go to Preferences > Gradle and uncheck "Offline work"
If Gradle is in offline mode, which means that it won't go to the network to resolve dependencies.
I am simply not able to bring the PAHO / Eclipse MQTT Android Service into an Android Studio project.
The PAHO documentation advises you to add this line to app/build.gradle
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
But eventually I discovered that is now obsolete, and that line should actually be:
api('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
Complete app/build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.rlasater.mqttsubscriber"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
//implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
//This is the problematic line:
api('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
}
Result when I attempt to build:
Build failed
:app:compileDebugKotlin
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class androidx.appcompat.app.AppCompatActivity, unresolved supertypes: androidx.core.app.TaskStackBuilder.SupportParentable
app/src/main/java/com/rlasater/mqttsubscriber/MainActivity.kt
Cannot access 'androidx.core.app.TaskStackBuilder.SupportParentable' which is a supertype of 'com.rlasater.mqttsubscriber.MainActivity'. Check your module classpath for missing or conflicting dependencies
<Previous line repeated several times ...>
Compilation error
What needs to be done so an Android Studio project can include the MQTT Android Client?
Why does that problematic line disrupt the basic Android class AppCompatActivity? That makes absolutely no sense.
Any suggestions would be most appreciated. I can't find any documentation on the PAHO MQTT Java/Kotlin more recent than some years ago. I have been able to get simpler classes (MqttClient) to work in the Studio. Obviously getting this Service working would be most beneficial.
Use following dependencies in build.gradle and check:
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.2'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
Documentation is not up to date.
dependencies {
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.4'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
// other dependencies
}
Latest releases You will find here
https://repo.eclipse.org/content/repositories/paho-releases/org/eclipse/paho/org.eclipse.paho.client.mqttv3/
https://repo.eclipse.org/content/repositories/paho-releases/org/eclipse/paho/org.eclipse.paho.android.service/
So I am assuming I have differing versions of dependencies causing this issue but i cant seem to resolve it.
When I add the dependency: implementation 'com.google.android.gms:play-services-vision:18.0.0' Then I get an error Syncing my build gradle.
When I change the version to implementation 'com.google.android.gms:play-services-vision:15.0.0' Then It Syncs fine but my app keeps crashing as soon as I open it.
Please can someone help me sync my versions so my app doesnt crash.
I changed the version from 18.0.0 to 15.0.0.
My gradle:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ecommerce"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.rey5137:material:1.2.5'
implementation 'com.android.support:cardview-v7:+'
implementation 'com.android.support:recyclerview-v7:+'
implementation 'io.paperdb:paperdb:2.6'
implementation 'com.android.support:design:28.0.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.sup`enter code here`port.test.espresso:espresso-core:3.0.2'
}
After some research I actually found out that Google stopped updating com.google.android.gms:play-services after 12.0.1. I changed the versions as well as my Firebase versions. Everthing Synced with no errors and seems to be running fine now.
first go to file and sync project with gradle file.. if it repeat itself, then go to file and invalidate caches/Restart it has work for me alot of time and also try and replace minSdkVersion 15 to minSdkVersion 21 and also with the look of it your firebase dependence are old check out https://firebase.google.com/docs/android/setup or google firebase dependencies
also make sure you add allprojects
{
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
to your build.gradle
In my app where I use firebase, firebase-ui, google maps, among others, it worked perfectly. I want to update to the latest version of each library and install Firebase Performance.
The error I get is:
error: cannot access InternalTokenProvider
class file for com.google.firebase.internal.InternalTokenProvider not found
And when I click on this error it sends me to an Activity to this line:
auth = FirebaseAuth.getInstance();
Here's my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
android {
signingConfigs {
release {
//signin things
}
}
compileSdkVersion 28
defaultConfig {
applicationId "app.example.asd"
minSdkVersion 21
targetSdkVersion 28
versionCode 22
versionName "2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
signingConfig signingConfigs.release
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-perf:17.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.facebook.android:facebook-android-sdk:4.42.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation "com.google.firebase:firebase-auth:16.0.1"
implementation 'com.firebaseui:firebase-ui:4.3.2'
implementation 'com.facebook.android:facebook-login:4.42.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-places:16.1.0'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.1.1'
implementation 'com.facebook.android:facebook-share:4.42.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//kt y rxjava
implementation 'androidx.core:core-ktx:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5#aar'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
//lib en kt
}
repositories {
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
Can anyone detect where the problem is in my dependencies? Thank you
UPDATE
With Peter's help I was able to correct the error, changing from firebase-auth:16.0.1 to firebase-auth:17.0.0.
Now I'm getting another error when I install and open my app, this is it:
java.lang.RuntimeException: Uncaught exception in Firebase Database runloop (3.0.0). Please report to firebase-database-client#google.com
at com.google.firebase.database.android.AndroidPlatform$1$1.run(com.google.firebase:firebase-database##16.0.5:98)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListener;
The error appears the first time I use this line in my app:
myRef = FirebaseDatabase.getInstance().getReference();
It looks like you are pulling in com.google.firebase:firebase-database:16.0.5 via the dependency on com.firebaseui:firebase-ui:4.3.2 (https://github.com/firebase/FirebaseUI-Android/releases/tag/4.3.2)
Try adding this to your build.gradle:
implementation 'com.google.firebase:firebase-database:17.0.0'
Also, generally check you are using the latest versions, which can be found at https://firebase.google.com/docs/android/setup#available-libraries
NOTE: This is based on the new error in your update after changing from firebase-auth:16.0.1 to firebase-auth:17.0.0
Change this:
implementation 'com.google.firebase:firebase-auth:16.0.1'
Into this:
implementation 'com.google.firebase:firebase-auth:17.0.0'
Upgrade everything(Firebase Auth, Cloud, etc) to the latest versions by just hovering mouse over it.
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
or:
implementation 'com.google.firebase:firebase-analytics:17.4.1'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.1'
Sync to this version and see.
If not, upgrade the Firebase tools on Android Studio.
UPD. I have read these question and answer (Class file for com.google.android.gms.internal.zzaja not found). But I doesnt understand what strings i need to add or remove in my project.
Because I havent this and other strings in my code:
compile 'com.google.android.gms:play-services-location:9.2.0'
I develop an android app with use of FireBase. And when I want to build my project I have an error:
Error:(39, 25) error: cannot access zzanb
class file for com.google.android.gms.internal.zzanb not found
The error was caused by invoking statement: FirebaseAuth.getInstance().getCurrentUser();
Projects build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Modules build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "xxx.yyy.zzz"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.firebase:firebase-core:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.1.0'
compile 'com.firebaseui:firebase-ui:0.6.0'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
}
apply plugin: 'com.google.gms.google-services'
Please, help me to solve that error)
P.S I have already read that question (Firebase Error cannot access zzanb after using play-services-xxx:9.8.00), but i didnt understand anything, what i need to add or remove from my build.gradle files in my situation.
You're mixing libraries from old and new Firebase released. Everything from Firebase that you use should be in parity. This line is reference an library from a very old Firebase release (before it became the Firebase platform at Google):
compile 'com.firebaseui:firebase-ui:0.6.0'
If you want to use the Firebase-UI library, you should use the new version of it that matches the version of the main client library you're using. You're using 10.0.1, so according to the table on the Firebase-UI github I just linked, you want this dependency:
compile 'com.firebaseui:firebase-ui:1.1.1'
Always make sure your Firebase-UI library matches the core Firebase SDK you're using.
It looks like in your case Doug's fix resolved your issue, but we recently encountered the same problem with a different root cause.
In our case, we had configured our IDE project to use JDK8 but failed to check which version of the JDK was in use in the terminal. Because React Native runs Gradle from the command line when you type 'react-native run-android' Gradle was attempting to build using JDK10 which caused obvious issues since Android currently only supports up to JDK8. Once we configured the terminal to use JDK8 the issue was resolved.
TL;DR: Check what version of the JDK you are using in the terminal.
Getting following error:
error: cannot access zza
class file for com.google.android.gms.common.internal.safeparcel.zza not found
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-analytics:17.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
/* implementation 'com.google.firebase:firebase-core:9.2.0' // this line must be included to integrate with Firebase
implementation 'com.google.firebase:firebase-messaging:10.2.1' // this line must be included to use FCM*/
//implementation 'com.google.android.gms:play-services:10.2.1'
implementation 'com.google.android.gms:play-services-maps:10.2.1'
implementation 'com.google.firebase:firebase-core:10.2.1'
implementation 'com.google.firebase:firebase-messaging:10.2.1'
}