I'm following this article to collect flows in UI. But I couldn't resolve repeatOnLifeCycle API in my code. I have added the below dependency, though.
lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
Please help
It's not
lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
but
androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
I hope this gradle config can help you.
def lifecycle_version = "2.4.0"
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
With this set, i resolve "repeatOnLifecycle" with this import:
import androidx.lifecycle.repeatOnLifecycle
I also had a similar issue. For me, adding the following in the dependencies section of the build.gradle file (the App Module one and not the Project one) helped to resolve the issue:
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03"
I also removed the import androidx.lifecycle.Lifecycle that was already there in the problematic file and got Android Studio to import the right one just in case the old one was wrong.
Found the latest version number to use(i.e. the "2.4.0-alpha03" part) from the following link but I think Android Studio would have later given a hint on the latest version to upgrade to anyway even if I hadn't done this:
https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-runtime-ktx/2.2.0-alpha01
Note: These APIs are available in the lifecycle:lifecycle-runtime-ktx:2.4.0-alpha01 library or later.
lifecycle-runtime-ktx
for me changing gradle from offline to online somehow solved the problem :/
I'm want to implement Twitter login in my app, but I can't import any of the related classes.
In my gradle I added:
implementation 'com.twitter.sdk.android:twitter:3.3.0'
gradle sync works fine, app compiles and run, but I'm not able to import any of the com.twitter classes like TwitterConfig. If I write "Twitter" and let Android Studio suggest me the only option I get are TwitterAuthCredential and TwitterAuthProvider both from com.google.firebase.auth.
What is going on? Am I missing some gradle line?
I managed to solve it importing only the dependecies I needed:
implementation 'com.twitter.sdk.android:twitter-core:3.3.0'
implementation 'com.twitter.sdk.android:tweet-ui:3.3.0'
implementation 'com.twitter.sdk.android:tweet-composer:3.3.0'
implementation 'com.twitter.sdk.android:twitter-mopub:3.3.0'
It migth be related to the large size of the library.
As Google APIs for Android introduced breaking changes as here I found my self un able to compile my react native android app, there are two things I need to know about:
How to avoid migrating to AndroidX and compile my project as I did before?
For example, when I have this error:
node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/ReactNativeFirebaseAppRegistrar.java:20: error: package android.support.annotation does not exist
import android.support.annotation.Keep;
how would include that missing package into build.gradle of that module?
I tried:
dependencies {
compile 'com.android.support:support-annotations:27.1.1'
}
but it did not help..
You can disable or avoid androidX with the following step
go to your android/gradle.properties file and paste or update the following
android.useAndroidX=false
android.enableJetifier=false
Although it does not update libraries we import or install, So all the libraries should be in AndroidX support otherwise project will not compile with this change I'm also having the same issue in my case project is fine but the problem is with the library called mapbox which have not support androidx I post the issue here you can check issue and comments.
I'm currently upgrading an app to the new Firebase version. I followed the guide, included classpath 'com.google.gms:google-services:3.0.0' in the dependencies of my project build.gradle as well as compile 'com.google.firebase:firebase-core:9.0.1' among others in the dependencies of my module build.gradle and also apply plugin: 'com.google.gms.google-services' at the end of that file.
I get a "cannot resolve symbol 'firebase'" in my imports i.e. import com.google.firebase.database.DatabaseReference;. Those are not errors that appear when building, so this seems to be working, but they are visible in the code editor of Android Studio.
The imports worked just fine a couple of days ago (except for FirebaseAuth, which was under maintenance). I did not change anything about the code since then (except trying to upgrade to 9.0.2, which lead to the same result). The only thing I did was update some components of the Android SDK, but I can't remember which. The Android SDK as well as Google Repository and Google Play Services are of the newest version. Rebuilding, cleaning and invalidate caches / restart had no effect.
Any ideas how to fix this?
You need to add this dependency in your build.gradle(app)
compile 'com.firebase:firebase-client-android:2.5.0'
Now with New Android Studio ,Its so easy to add Firebase to your Project.
Below are Simple Steps-
1. On Android Studio’s Tools menu, you’ll see an entry that reads Firebase.
2. Select this, and a Firebase Assistant pane will open to the side of your code editor:
3. On this pane, click the arrow beside ‘Authentication’, and you’ll see a step through for ‘Email and Password Authentication’.
4. Click the ‘Connect to Firebase’ button.
Your browser will open with a ‘Request for Permissions’ dialog:
5.Click ‘Allow’, and then after a ‘Success!’ screen, you’ll be given a dialog with which to connect to Firebase.
6.You will see Connected .Its Done !
For more on Firebase refer here.
You can open and use the Assistant window in Android Studio by following these steps:
Click Tools > Firebase to open the Assistant window. And it will guide you for sync firebase and your project.
Make sure you fulfill the following prerequisites before adding firebase to your project.
For working with Firebase you should install Android Studio 1.5 or higher.
Download the latest Google Play services SDK from through Android SDK Manager.
The device should be running Android 2.3 (Gingerbread) or newer, and Google Play services 9.2.0 or newer.
I find out all this after hours of struggle, so thought of sharing with others.
Source: Adding Firebase to your Android App
Invalidating cache didn't work for me. But deleting .idea/libraries worked like magic.
More info here: https://stackoverflow.com/a/50129167/971972
Add following in your gradle file under dependencies:
compile 'com.firebase:firebase-client-android:2.5.2'
If you are getting a build error complaining about duplicate files you can choose to exclude those files by adding the packagingOptions directive to your build.gradle file:
android {
...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
To use the Firebase Messaging service you need to add the following dependencies to your app's build.gradle file:
compile 'com.google.firebase:firebase-messaging:9.4.0'
I had the same problem but thanks to this answer:
https://stackoverflow.com/a/39353961/4836759
In the new SDK, it's no longer necessary to call Firebase.setAndroidContext() so you can remove it from your code.
In the new SDK, Firebase references are replaced by DatabaseReference and you use the FirebaseDatabase class to get an initial reference to your database. So you can get the database reference in your code as follows:
BEFORE
Firebase rootRef = new Firebase("https://.firebaseio.com/");
AFTER
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
Note that your Database URL is automatically determined from the google-services.json file you downloaded, so you don't need to specify it. If you want to specify it though, you still can (which might be convenient for migration purposes):
BEFORE
Firebase ref = new Firebase("https://.firebaseio.com/path/to/data");
AFTER
DatabaseReference ref = FirebaseDatabase.getInstance()
.getReferenceFromUrl("https://.firebaseio.com/path/to/data");
22
After adding it in from the built in Firebase tool and also following the following a tutorial, the imports did not work on one of my classes so all you have to do is sync the gradle files
Tutorial I've used:
https://www.androidtutorialpoint.com/firebase/firebase-cloud-messaging-tutorial/
Tools/Android/Sync Project with Gradle Files.
Works 100% now
You need the Firebase client library. Add this to your app gradle:
dependencies {
// Firebase
implementation 'com.firebase:firebase-client-android:2.5.2'
Replace 2.5.2 with the latest version (there is probably a new one out there since I posted this answer).
dependencies should be used in the latest gradle version (not compile).
I am trying to use clustering in my application. However on the import statements I get 'the import com.google.maps cannot be resolved (clustering.Cluster).
Also, when using ClusterManager I get 'cannot be resolved to a type'.
The rest of the google play services are working fine.
Are you using Android Studio, or Eclipse? Might need to check your gradle file (Android Studio for example) to see if you have the library/module dependencies lined up. If you are using this library (https://github.com/googlemaps/android-maps-utils) for example, your gradle file should have something like :
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.3+'
}