setting library versions issue - android

Setting the right versions for Gradle dependencies has always seemed, to me, to be an arcane science. For instance take the following line . . .
implementation 'com.firebaseui:firebase-ui:+'
If I build the project with that line I get version 12.0.1 which should be the latest version. No?
If I place my cursor on the + and hit alt-enter and choose "Replace with specific version" I get version 2.1.0. I recall reading somewhere that I should get the latest version stated specifically instead of, in this case, 2.1.0.
So I guess the most dependable way to find the latest version of a library is to compile with + and look to see what I get.

When there is an update android studio show a warning and a mouse over is enough to show you the latest library.
This works great for all google-android components.
For other third party libraries I usually add a link comment in order to check regularly if there is something new.
Note that in the white theme the warnings are not so clear as in the black theme.

Related

Android Studio lint highlight with Timber not working

I've integrated Timber into a new project.
And I cannot make the lint highlight to work. Meaning stuff like this:
Timber.i("Hello, " + "world!");
Isn't highlighted to yellow.
Am I missing something? Is there a setting for this?
Running a ./gradlew lint generated a lovely report which finds exactly what I want, so the lint rules are somewhere in my project. Yet the IDE does not want to highlight that on the fly.
Things like new String("x") are highlighted, and mostly my IDE settings are default, so something works.
I have another bigger project with Timber and highlights work perfectly - so there is my suspicion that I'm missing something on the level of project config.
This was an issue with Android Studio 2.3 & Timber 4.5.1 or earlier.
If you upgrade Android Studio to 3.0 & Timber to 4.6.0 you should get this highlighted correctly. There was an issue in the Android Source Code and also in Timber. This was fixed now in both recent versions though.
You can see the Timber fix and a gif with your showcase here.

Android Studio: can no longer see dependencies javadoc

Android Studio v3.0 Canary 4,
but happens for me on Android Studio v2.3.3 too
I'm not sure since when this started to happen, what version or configuration I've made (if any), but I can no longer see libraries/dependencies javadoc:
for instance, RxJava:
Even though, Android SDK does show the javadocs correctly:
This is true for all libs I have, I looked everywhere on the net for this issue, and it seems like I'm the only one.
As a workaround, you can manually specify JavaDoc.
Navigate to jar file, select "Library Properties", click "Specify Documentation URL".
For RxJava 2.x: http://reactivex.io/RxJava/2.x/javadoc/
For RxJava 1.x: http://reactivex.io/RxJava/1.x/javadoc/
Detailed how-to can be found here
It's a bug. Allegedly it was fixed last month, but from what I've seen some extra monkeying is needed to get the correct behavior back - I downloaded the latest Android O artifacts from the SDK Manager, then temporarily changed all build.gradle settings to support Android O, then switched back, and now I see the javadoc again even without supporting O. Here's the bug report: https://issuetracker.google.com/issues/37140074
What you can do as a workaround is to inspect a class in the dependency, and it'll give you the decompiled byte code with an option to "Download...". Click that, source is downloaded, and now you have javadocs. You have to do this for each dependency, but it persists through cleans and resyncs.

Android Studio : How to find latest version number of google specific libraries?

How to find latest version number of google specific libraries from repositories (jcenter etc..) to include in gradle dependencies in Android Studio.
For non google libraries generally I can make a search in jcenter itself. But not able to search google specific libraries there.
You may take example of following libraries.
com.android.support:appcompat-v7:25.1.0'
com.android.support:recyclerview-v7:23.3.0'
Yes as Tim mentioned in the comment Gradle tells you by highlighting particular dependency as a warning.
Trick to update dependency with latest version:
Let me also share a trick through which you can always include the latest version of the particular dependency.
Replace the version number with only "+" sign.
Sync gradle
Now select + sign and press ALT + ENTER, it will show you drop down menu with an option to select latest version.
If you have added a dependency, you can see them by moving the cursor to that library. It will show you a warning
You can then change to new library and sync your project.
Another way to use the latest libraries in Android Studio.
Right click your project and choose Open Module Settings. Project Structure window will appear. Select 'app' from the left pane and choose the 'Dependencies' tab. Include new library dependency by pressing the + icon. Search your needed library in the window opened up. Latest library dependency will appear in the suggestions and you can add them to your project.
The best way these days is to go to https://maven.google.com , where google now lets you browse all their libraries and see all the versions available, including the latest version. It looks like this:
You can even do a search for a specific library, and then expand/collapse as desired:

How do I find Google Play version?

When I am setting up gradle, I have to add something like:
compile 'com.google.android.gms:play-services:6.1+'
I don't like to use the +, so I can always know which version the project is being compiled with and so I can avoid some surprise bugs.
In order to find the Google Play version I have currently downloaded, I usually go to the library XML file which I can find something like: "6171000", which is the version as an integer.
Is it there a simpler way to figure out the version that I need to write on gradle?
cd into your module (eg: app) dir, and run gradle command line ..\gradlew -q dependencies --configuration compile. This will resolve the + , and show you exact version being used for your library. See below.
Or, if you use Android Studio, when you modify/edit the version (eg: simply delete/add + at the end), Android Studio will show a yellow-bulb action with Replace with specific version, click on it to automatically replace the + with exact version available.
Go to this site: http://gradleplease.appspot.com/#play-services
You can also search for any library (Ex. recyclerview). This will help you specify the library's latest version.

NotificationCompat cannot be resolved to a type

I am newer to Android and receive the error message: "NotificationCompat cannot be resolved to a type"
MinSDK=9, TargetSDK=18,
As of yet, all sources are very vague on how to resolve this issue and simply note: "update the JAR files".
What JARs do I need and where can I find them, so that this issue is resolved?
You need the support library. Here are the instructions on how to download them: http://developer.android.com/tools/support-library/setup.html
I needed to add "android-support-v4.jar" to my project to use the ActionBar.
From the support link (which has been updated)
With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX
From the menu: Refactor > Migrate to AndroidX...
You will be prompted to back up your project to a zip. After that, a Refactor Preview will be shown in the console area. You should see a button "Do Refactor".
This will remove the error under the noted conditions. You may find some lines of code now report as deprecated after the refactor.
Sometimes Eclipse gets hung up on this class, and no amount of cleaning and rebuilding will make it recognize that you have, in fact, added the support library and imported the correct class. I don't know why it always happens with this particular class. But the solution is to close and restart Eclipse.

Categories

Resources