Do I need Gradle dependency for RecyclerView? - android

I forgot to include this in Gradle -
compile 'com.android.support:recyclerview-v7:23.+'
But my project works fine without this record.
So, why do I need to write it in Gradle?
Can I use only appcompat?
compile 'com.android.support:appcompat-v7:23.2.0'

com.android.support:appcompat-v7 does not depend on com.android.support:recyclerview-v7, but com.android.support:design does.
There's no harm in including this dependency one more time in your build.gradle, but it's not necessary since design includes it.

Related

Gradle 3 `compile project` and `compile files` deprecated?

How would I translate those to implementation or api?
Fx. what should I replace those with?
compile project(':jabraServiceApi')
compile files('libs/samsung-digital-health-healthdata-1.2.1.jar')
Maybe compile project and compile files are still supported and should stay as they are?
Gradle 3.4 introduced new Java Library plugin configurations configurations that allow you to control whether a dependency is published to the compile and runtime classpaths of projects that consume that library. The Android plugin is adopting these new dependency configurations, and migrating large projects to use them can drastically reduce build times. The following table helps you understand which configurations you should use.
I already give the answer here please check compile configuration is now deprecated .

what compile must be change to implementation, I has been changed all

I has been changed all of compile in gradle to be implementation . But there is still warning in my project. do you know what I left behind? thank you
You have not left anything. The warning is just about the newer version of dependencies which are available and can be integrated into your project if you want.
And for "compile" related warning, just go to your gradle file and find "compile" keyword and then replace it with "implementation"

How do I properly specify dependencies in a published Android library?

I'm creating an Android library that will be published to something like Sonatype. Some of my classes depend on classes in the AppCompat library.
If my Android module look like this:
dependencies {
compile "com.android.support:appcompat-v7:25.3.1"
}
will my users run into problems if they add my library as a dependency and also add some future version of appcompat as a dependency?
And related, is there a way I can set this up so they don't have to specify transitive dependencies, or would that even be expected for ease of use?

The following classes could not be found: - android.support.design.widget.TextInputLayout

This is Tutorial which i am following.
Please help me out from this error. Rebuild is not solving the problem.
Does your build.gradle file contain the line below?
compile 'com.android.support:design:22.2.0'
You must include support libraries (like the ones below), yet this is sometimes not sufficient.
compile ("com.android.support:support-v4:23.3.0")
compile ("com.android.support:appcompat-v7:23.3.0")
compile ("com.android.support:support-annotations:23.3.0")
compile ("com.android.support:recyclerview-v7:23.3.0")
compile ("com.android.support:design:23.3.0")
Examine your layout in design view, and click on Show Exception
This answer will help if you have the following problem:
You need to use a Theme.AppCompat theme (or descendant) with the design library.
In your Manifest file, include in your application declaration
android:theme="#style/Theme.AppCompat"
Rebuild and your problem should be solved.
First things first :
If you are using the lastest sdk28 TextInputLayout is having some bug. At least mine did (date: 22 Sept 2018 ) NOT work.
To make it work the best way is to use slightly lower SDK for you target and compile SDK version. (I used sdk 27 and everything worked out fine then.)
To use TextInputLayout and then its features such as "floatinghinttext" you need to update your build.gradle(module.app) found in gradleScripts.
in dependencies add-
implementation 'com.android.support:design:25.0.0'
(if you get some error it must be of some latest version available, so use that instead of 25.0.0)
Note: The "compile" keyword is getting replaced by "implementation" for newer/all versions.
I am fairly new to android development, suggestions are welcomed. Please excuse if any mistakes committed.

Gradle dependencies update

One of the advantages of using Gradle in Android Studio is that it helps in dependency management. So if I have used a particular version of a library in my build.gradle file,
then how will I force it to update the dependency version once the higher version is available?
Some of the dependencies in my build.gradle are specified as
dependencies {
compile project(':facebookSDK')
compile files('libs/picasso-2.1.1.jar')
compile files('libs/crouton-1.8.1.jar')
}
One of the advantages of using Gradle in Android Studio is that it helps in dependency management.
Not the way that you are using it.
So if i have used a particular version of a library in my build.gradle file, then how will i force it to update the dependency version once the higher version is available?
In your case, you would download the new JARs, put them in libs/, and update your build.gradle to match.
The preferred approach is for you to delete those JARs and replace your two compile files statements with ones that pull down the dependencies from Maven Central or another artifact repository. You can find the proper statements for popular open source libraries like those via the Gradle, please site.
In your case, you would use:
compile 'com.squareup.picasso:picasso:2.3.3'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5'
These will require you to also have a repositories closure as a peer to your dependencies closure:
repositories {
mavenCentral()
}
This may already exist.
These compile statements still pin you to a specific version of those libraries, but moving to a new version would be a simple matter of updating the compile statement, and Gradle will pull down the new dependency on your next build.
If you want, you could replace part of the version number with a wildcard (e.g., 2.3.+). This will cause Gradle to automatically update to new patchlevels of the library, in this case. Some developers do not approve of this approach, as while it is convenient, it does reduce your ability to be able to reproduce a build (e.g., you need to recompile some older branch of your code, and now you don't know what version of the artifact you were using back then).
As you are compiling files from your local project, I don't think you can automatically compile a new individual jar version if available. What you can do instead of compiling individual files is:
compile fileTree(dir: 'libs', include: '*.jar')
This will compile all jars in the libs directory so you will always have the latest version.
Both the libraries you are using are available to be compiled as dependencies from mavencentral.
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5'
compile 'com.squareup.picasso:picasso:2.3.3'
If you want to ensure you are getting the latest versions is you use a plus in place of the version number. It's up to you how open you want to be with this.. so
compile 'de.keyboardsurfer.android.widget:crouton:1.+'
compile 'com.squareup.picasso:picasso:2.+'
will give you the latest version under the 1. or 2. versioning cycles...
If you want, you could replace part of the version number with a wildcard (e.g., 2.3.+).
This will cause Gradle to automatically update to new patch-levels of the library, in this case.
Some developers do not approve of this approach, as while it is convenient it does reduce your ability to be able to reproduce a build (e.g., you need to recompile some older branch of your code, and now you don't know what version of the artifact you were using back then).
I have found Gradle, please to be my answer here.
Easily get the latest android library gradle compile statement.

Categories

Resources