My Android application faced some freezing issues in some rare scenarios. After some research I found that this issue was caused by an Android bug which already was reported at issuetracker.google.com. Recently I got notified that the issue was fixed.
Now my question is, how do I make sure that this commit to AOSP that should presumably fix the freezes is already included in my project? It might have something to do with the build.gradle file, which looks like this:
dependencies {
implementation 'androidx.preference:preference:1.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
...
}
For every implementation, a version number exists. So do I have to wait until Google releases the latest version of the package in which the fix is included and then use this latest version? Or will I get the latest fix just by resyncing the project?
I apologize if this is a stupid question, but I did not quite understand yet how the sync between the AOSP repository and my Android project works. Thanks in advance for any help.
Link to the Bug on Issuetracker. It is required to log in with a Google Account to view the Issuetracker.
I would say 'androidx.appcompat:appcompat:1.2.0-alpha03'.
From the Issue Tracker we learn the link to the Patch that fixed the bug. In the patch page, we see the fix is in the 'appcompat' folder/library (the list of modified files at the bottom). Also, in the top-left, we see the repository and the branch where the patch was merged (repo platform/frameworks/support, branch androidx-master-dev). It is important that the patch is marked as MERGED. Only merged patches are integrated into released libraries.
Clicking on the branch link sends us to the repo/branch from which all androidx.* libs are built (See these instructions how to build androidx.* libs yourself and use them locally). Here we have to search for the patch that fixed that bug but the androidx repository receives a lot of patches and the list is pretty long. Fortunately, that search/filter box from top-right accepts a directory key. By adding 'directory:appcompat' in the search box we see only the patches from appcompat lib. It is easy to spot the 'Fix stopped Activities not resuming on < API 24' patch and right above it another patch 'Bump AppCompat version to 1.2.0-alpha03' that sets the version for the fixed appcompat lib.
Related
maybe it is because I don't understand it but choosing the right version of dependency libraries to specify in the build.gradle file is a big mess.
How do we know which versions to choose and which versions are compatible with other versions?
Now that I have discovered maven.google.com I think I can see all the versions available to me.
Most recently I am dealing with Firebase libraries. I need both messaging and core. At this writing messaging is at 17.3.4 and core is at 16.0.4. But if I build with those versions I get an error that says cannot access zzbfm - what ever that is.
I finally got a clean compile with the following but this combination was achieved by trial and error taking an hour or so...
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.google.firebase:firebase-core:16.0.3'
It would be nice if the answer were "always use the latest version" but that certainly isn't the answer.
What am I missing here?
You are not really missing anything. Version compatibility is mainly a thing of trial and error. What you can do:
Only add the artifacts you really use in your code. Don't add transitive dependencies.
Look at potential conflicts in the transitive dependencies and make trials, starting with the newer version.
Generally: Try to use as few dependencies as possible, this reduces the hassle.
I've been getting an error when syncing Gradle:
Could not find method compile() for arguments [com.android.support:support-core-utils:28.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
I've found solutions for previous versions but I've been developing for v28, and I'm not even sure if my compile "com.android.support:support-core-utils:28.0.0" line is correct. This is for a firebase chat app and I'm following a 2016 tutorial. I did end up installing the support thing from the manager but same error.
You can not use compile in version 4.4 of Gradle and instead reduce it by using implementation method
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.12'
I have also completed a quite similar tutorial - creating the "Flashchat" app.
I ran into the same problem - apparently they updated the keyword used in the gradle files:
build.gradle (Module: app) - you will find dependencies at the bottom.
There you will be able to add the firebase libary as well as other ones. Example:
implementation "com.android.support:support-core-utils:28.0.0"
Unfortunately, the tutorial from 2016 is outdated so you might find several of those little changes later on. For example creating the firebase database will be a little different because they introduced a Real Time Database. (You can still use the old one for your chat app but you will have to change the ruleset for read and write access.)
For further questions you might run into, I recommend searching for "Flashchat" on GitHub. Many people have followed that tutorial and have uploaded their results. This might solve upcoming questions by just comparing the code and then looking up the documentation to understand what has changed. Link to GitHub
I wanted to get started with learning to code for android devices and for this i've bought a course on udemy. Unfortunately after the third video I couldn't go on because of some very annoying problems in the Android studio version 3.1.3. I tried to solve the problems but since i'm just a very beginer in programming and espacially in java I didn't stand a chance to solve it on my own and sadly every solution which i've found on the internet didn't function. So here is my problem.
Every time I start a project (no matter which) the layout won't load. And then I get this 4 messages.
Pic 1
Pic 2
I think the render problem is because of the missing styles and the missing styles are because of the classes which failed to instantiate. I think the private ressources problem is independent. So I really have no clue how to solve this problem. I think i tried almost everything. Is it possible that it has something to do with the java development kid? I've downloaded the newest version but I'm not sure if Android Studio is using it. Or maybe something with the normal java software is wrong.
Maybe the build.gradle will help you to find a solution:
pic 3
I really appreciate your time and your answers and if you need some further information please let me know.
Thank you and kind regards
Gmunderos7
UPDATE:
I've downloaded both versions on this website:
https://developer.android.com/studio/preview/?utm_source=android-studio
And both of them don't have this problems (just the private ressource). Would you recommend using one of the versions (or maybe an older version than 3.1.3 which don't has this problems)?
And can someone even use version 3.1.3 without such problems?
Step 1: "File" -> "Invalidate caches / Restart" -> "Invalidate"
Step 2: "File" -> "Close project"
Step 3: In launcher window delete your project
Step 4: Open your project by "Open an existing Android Studio project"
Step 5: Write nice code :)
I had the same problem and i fixed it today, I changed my dependencies into these
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'android.arch.core:runtime:1.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.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.google.firebase:firebase-core:16.0.0'
apply plugin: 'com.google.gms.google-services'
}
This question already has an answer here:
How to add firebase-admin to my android project?
(1 answer)
Closed 5 years ago.
I'm developing an Android app using Firebase, and went to install the Admin SDK using this tutorial. In my build.gradle file in my app, I've had a couple of dependencies that have given me warnings since I added them earlier in the project, but I was still able to run the application. Once I added the dependency needed for Admin SDK, things got a little more serious...
These are the original dependencies and their warnings:
implementation 'com.google.firebase:firebase-core:11.8.0'
All gms/firebase libraries must be the exact same version specification. Found versions 9.6.0, 11.8.0
implementation 'com.android.support:appcompat-v7:26.1.0'
All com.android.support libraries must be the exact same version specification. Found versions 26.1.0, 23.4.0
I searched the whole project using the double-shift search function in Android Studio and couldn't find anything that used either of the conflicting versions mentioned (9.6.0 or 23.4.0).
Like I said, the app still ran so I carried on developing. While adding the Firebase Admin SDK, I added the following dependency to my build.gradle:
implementation 'com.google.firebase:firebase-admin:5.6.0'
When I hit 'sync' on my gradle, I got the following error:
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.8.0.
This has left me a bit confused as I believe the most recent version of com.google.firebase:firebase-admin to be 5.6.0, so I don't see how I can be getting a version conflict for using this.
My app won't run while this error exists, so any help getting past it would be very much appreciated. I'm new to Android development so it might well be something very obvious that I've missed.
Here is my full list of dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0' <-- warning
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:11.8.0' <-- warning
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.firebaseui:firebase-ui:0.6.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-admin:5.6.0' <-- introduced error
implementation 'com.google.firebase:firebase-messaging:11.8.0'
}
If I can include anything else that will help with diagnosing, please let me know!
Thanks in advance,
Mark
The Firebase admin SDK is meant for JVM servers and can't be used in tandem with client SDKs. See this great post for more details. I would recommend using Cloud Functions for admin stuff instead since they're something you control and can't be compromised on the client.
Some dependencies like com.android.support libraries must use the same versions in all libraries. The lint error GradleCompatible states that there can be runtime crashes if the versions differs.
This Lint check has been around for a while, I did no see it in the project I work on until recently, maybe support lib 25.0
The dependencies may not always be in sync with the version in the main project and eachother. This is a problem where the dependencies cannot be controlled.
In the project RunnerUp there are two projects that are open source and can be compiled manually (MapBox, GraphView) - assuming that the dependencies can be updated or downgraded. However there are two Google dependencies that uses separate versions: com.google.android.support:wearable:1.4.0 (23.0.1) and com.google.android.gms:play-services-wearable:10.0.1 (24.0.0)
How should GradleCompatible be handled, is there any solution or should the error just be suppressed?
A little more info in a pull request for an attempt to workaround (maybe without any effect).
https://github.com/jonasoreland/runnerup/pull/519
Edit: It seem like adding the offending support libraries will cause the libraries to be compatible.
Snippet (see PR for details).
app:
//support-v4 is not used by app source but wearable, mapbox
//force same version as in the app
latestCompile "com.android.support:support-v4:${rootProject.ext.supportLibrary}"