androidx.annotation.NonNull Cannot resolve symbol 'NonNull' - androidx

I have an issue after I deleted and updated some libraries from my project when I open any class that imports androidx.annotation.NonNull; I see error that Cannot resolve symbol 'NonNull'
I do a search and found that I should add to Gradle implementation "androidx.annotation:annotation:1.5.0", but the error still appears.
When I try to click Alt+Enter he changes the import to
import io.reactivex.annotations.NonNull;
My Gradle
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.annotation:annotation:1.5.0"
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.github.pwittchen:reactivenetwork-rx2:3.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'com.j256.ormlite:ormlite-android:6.1'
implementation 'com.google.code.gson:gson:2.10'

The issue was fixed after I updated the android studio version!

Related

why having this error 'deprecated API' when trying added firebase to flutter

I am Facing error while trying to add Firebase on Flutter project.
when I run the app error appear:
Launching lib\main.dart on sdk gphone x86 in debug mode...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-
1.0.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or
overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-
1.0.1\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestorePlugin.java
uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore- 1.0.1\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.
java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth- 1.0.1\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java uses or
overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:50487/Plr_UpKjauM=/ws
One of these things, or a combination of them, should send your problem away
Upgrade your build version to 23 in android/app/build.grade file
flutter clean
In android/app/build.grade, update dependencies like
dependencies {
...
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Run flutter pub upgrade in terminal or pub upgrade from the pubspec.yaml file
Try this answer https://stackoverflow.com/a/59531270/13858991
Will check on some more known ways to fix it and let you know when I update the answer

ERROR: Failed to resolve: com.google.android.material:material-rc01: Affected Modules: app

After adding 'com.google.android.material:material-rc01' in place of com.android.support:design as per documentation, studio failed to detect the dependency.
Then I downgrade the version of dependency to
implementation 'com.google.android.material:material:1.1.0-alpha09'
and it works.
But why this problem arises? any explanation?
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-
jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material-rc01'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso core:3.2.0'
}
ERROR: Failed to resolve: com.google.android.material:material-rc01:
Affected Modules: app
The error arises due to the fact that you're not specifying a version for the implementation; the program needs the following:
The group
The name of the dependency to implement
Version of the dependency
All this is covered in more detail here
When I got this error message, I solved it with the below line:
implementation 'com.google.android.material:material:1.0.0-rc01'
As you can see, the line above follows the implement 'compileGroup:name:version' pattern from the list, which in this case is 1.0.0-rc01; -rc01 seems to be a name for the version, just like -alpha09.
Note as well that you are not downgrading as you say if you didn't specify a version previously, which is why your app couldn't build.
I just had the same issue. I solved it by using the following dependency:
implementation "com.google.android.material:material:1.0.0"
To solve such issues you always can check if the lib you are looking for does really exists in Google's Maven repo: https://dl.google.com/dl/android/maven2/index.html
Hope that help, cheers!

Firebase Failed to resolve: firebase-messaging-15.0.0 (Previous solutions disconnect Firebase Connection)

I have been trying to set up Firebase Cloud Messaging on an app. Everything runs ok until I add FCM dependencies to the app. I immediately get this error:
Failed to resolve: firebase-messaging-15.0.0
Open File
Here are the dependencies;
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
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'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
I have been reading answers like this all day and the only solution that works involves deleting everything from ": - 0" in the last line of the code.
The problem is that it immediately removes the connection to FCM. New to android programming, so forgive any obvious oversight. Thanks
This happens because the version of the dependencies conflict. You can remove one of the version and select the preferred one. In this case your
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
seems to have double version. You should choose whether to use 17.0.0 or 15.0.0 one.
The detail can be found in this video
https://youtu.be/NN_Ch5qzFWQ
cheers !

Migration to androidx.databinding on AndroidStudio 3.0

I'd like to ask if it's possible to migrate to androidx.databinding in AndroidStudio 3.0.
I don't want to upgrade to AndroidStudio 3.2 just yet, and it seems that I can only import android.databinding instead of the androidx version.
I have added this in my app gradle file:
kapt "androidx.databinding:databinding-compiler:3.2.0-alpha16"
Project gradle dependency:
classpath 'com.android.tools.build:gradle:3.1.0'
All the other androidx libraries I added on gradle can be imported in code, but not databinding. Has anyone here still using AndroidStudio 3.0 successfully used androidx.databinding?
Thanks.
UPDATE:
In the app build.gradle, I updated the dependency from -jre8 to -jdk8:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
This is the app build.gradle dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$rootProject.supportLibVersion"
implementation "com.google.android.material:material:$rootProject.supportLibVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
// architecture components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime:$rootProject.archLifecycleVersion"
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.paging:paging-runtime:$rootProject.pagingVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
kapt "androidx.databinding:databinding-compiler:3.2.1"
testImplementation 'junit:junit:4.12'
}
configurations {
all {
exclude group: 'com.android.support'
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
And this is the project build.gradle versions:
ext {
archLifecycleVersion = '2.0.0'
roomVersion = '2.1.0-alpha02'
pagingVersion = '2.1.0-beta01'
supportLibVersion = '1.0.0'
}
I executed this to find out more about the issue on my project:
./gradlew :app:kaptDebugKotlin
and I got this error:
e: error: cannot access NonNull
class file for android.support.annotation.NonNull not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.support.annotation.NonNull not found
e: [kapt] An exception occurred: java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V
at org.sqlite.core.NativeDB._open_utf8(Native Method)
at org.sqlite.core.NativeDB._open(NativeDB.java:71)
at org.sqlite.core.DB.open(DB.java:174)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:220)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
at org.sqlite.JDBC.createConnection(JDBC.java:114)
at androidx.room.verifier.DatabaseVerifier$Companion.create(DatabaseVerifier.kt:81)
So it seems that the underlying sqlite library is still using android.support.annotation.NonNull. Any idea on how to solve this?
Thanks.

Flutter: Build errors for cloud_firestore: above version "0.7.4"

I have been trying to resolve a build issue for hours until I realise it is due to Flutter plugin cloud_firestore. Version 0.7.4 builds fine for both Android and iOS but anything above 0.7.4 like 0.8.2+1 will have errors such as:
CloudFirestorePlugin.java:160: error: cannot find symbol
query = query.whereArrayContains(fieldName, value);
^ symbol: method whereArrayContains(String,Object) location: variable query of type
Query
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:598:
error: cannot find symbol
builder.setTimestampsInSnapshotsEnabled(
^ symbol: method setTimestampsInSnapshotsEnabled(Boolean) location: variable builder
of type Builder
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:678:
error: cannot find symbol
return FieldValue.arrayUnion(toArray(readValue(buffer)));
^ symbol: method arrayUnion(Object[]) location: class FieldValue
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:680:
error: cannot find symbol
return FieldValue.arrayRemove(toArray(readValue(buffer)));
^ symbol: method arrayRemove(Object[]) location: class FieldValue Note:
/Users/peterlumdev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. 4 errors FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org BUILD FAILED in 11s Gradle task assembleDebug failed with exit code 1
I would like to use 0.8.2+1 cloud_firestore for both ios and Android because of the support of
await db.settings(timestampsInSnapshotsEnabled: true);
Appreciate some help here. Many Thanks!
There is a problem with google-services.json.
In my case, I was in the same situation while coding Firebase for Flutter on Google Codelabs. I put GoogleService-Info.plist in Xcode in the corresponding folder and put google-services.json in the corresponding folder in Adndroid Studio as well. iOS Simulator worked, but in Android Studio the window like the one below is displayed, then pressing the OK button and launching Android Emulator resulted in the corresponding error.
When coding from scratch and inserting the google-services.json file from the Finder instead of Android Studio, no error occurred.
It's not working because it is creating a gradle conflict. Version 0.7.3 of firestore is working because gradle tooling is updated at that version. Please refer changelog and also refer this answer for any other working versions of firebase products.
I feel you, I've also spent hours and hours trying to figure this out.
After building a SSCCE, and then applying the settings of that project to my project, and then some tweaking, I got my project working.
Although I adjusted more settings than I care to remember, these seem to have had the highest impact:
In pubspec.yaml:
# included two other common libraries others might use
cloud_firestore: 0.8.2+1
firebase_auth: 0.7.0
google_sign_in: 3.2.4
Explicitly disable these two features in android/gradle.properties :
android.useAndroidX=false
android.enableJetifier=false
Use these versions of dependencies in android/build.grade:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
And finally, use these settings in android/app/build.gradle:
android {
compileSdkVersion 27
...
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
...
}
...
}
...
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
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'
compile 'com.android.support:multidex:1.0.3'
}
It's also worth noting that I downloaded the google-services.json file again (though that didn't have any effect just by itself).
Any combination of these settings might help you.

Resources