I have created a library in Android Studio and wanted to give it to someone for testing.Besides maintaining it in the svn I am providing the version of the library hardcoded in the Library code which I keep on changing everytime I build and send it for testing to track the record.
The code is as below :
defaultConfig {
..
..
..
versionName "0.00.0012"
}
and then getting the version of the Library as BuildConfig.VERSION_NAME
Does the App version will change in the AndroidManifest.xml as well automatically?
is there any other way of managing the various lib versions?
android:versionName="not the same version"
Does the App version will change in the AndroidManifest.xml as well automatically?
No, library version will not influence application's version in any way. Both are separate.
is there any other way of managing the various lib versions?
What you do lets the consumer check the version of the library in code, which is fine. If you want to actually distribute new versions of the library then you'd probably want to use a maven repository - either local or a remote one, and push your library there with given version. This is the version you then reference in compile 'com.my.library:library:1.2.3'.
Related
Android studio will show you if there is a newer version of a library when the version number is hard coded. But if you use variables, this seems to short circuit that functionality. Is there any way to get it back? I want to see available updates in build.gradle without having to Inspect the project.
Gradle 6 offers a new way to recommend and share versions between projects called platforms. This allows you to specify a set of dependency versions to share across projects without using variables.
You can use the Java Platform Plug-in to create a platform; a special kind of project that only contains a list of dependencies that work together. I haven't tried this, but hopefully Android studio will alert you if any of these versions are out of date since you'll be using hard coded version numbers.
You can then reference your platform in your other projects using the platform keyword and load all the other dependencies without versions
dependencies {
// get recommended versions from the platform project
api(platform(project(":platform")))
// no version required
api("commons-httpclient:commons-httpclient")
}
As the title mentions, I am using buildSrc and Kotlin for Gradle Dependency management in a modularized android project as per the following tutorial:
https://caster.io/lessons/gradle-dependency-management-using-kotlin-and-buildsrc-for-buildgradle-autocomplete-in-android-studio
it's working all fine but the question is how can I be notified if there are any libraries that have an update on their version? (i am not getting the notification on the library where it gets marked showing that there is an update)
is there another way of doing this?
There are a few approaches you can take here:
Leave out the dependencies in build.gradle. Currently, there is no hint shown in Android Studio if you extract out them into variables. So you can just use strings here.
Use Gradle-versions-plugin to check for dependency updates. You can read more about this here.
In my mind, androidx.* is optional for an Android project, I find that androidx.* is necessary when I update to Android Studio to 3.4.2.
See the Image. So androidx.* will be standard, right?
Image
AndroidX is a major improvement to the original Android Support Library.
Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases. androidX fully replaces the Support Library by providing feature parity and new libraries.
Here
If your app currently depends on the original Design Support Library, you can make use of the Refactor to androidX option provided by Android Studio. Doing so will update your app’s dependencies and code to use the newly packaged androidx.
New Design support library requires andriodX migration too! You should consider using androidX for your future projects! Here
Add the library to the in your build.gradle(app-level) dependencies section:
implementation 'com.google.android.material:material:version' Latest Version
you can still make app absolutely..androidx is just a extension of the android library itself...so if you completely know android libraries,you can make any app,same as what androidx can,as the name implies,its a "support library" so without using it you can still make full blown app...again its a support library to make your life not worrying of compatibility for your app,but if your really know android programming,your dont need androidx.infact making app in android(not androidx)is better because you dont need transitions in the future same to what happen to those who rely on android support libraries..
I am using compile 'com.localytics.android:library:3.8+' in my project.
I want to know that is the latest version of this dependency is picked when the release apk is created or every time when the user opens the app (downloaded from playstore).
You should avoid the use of the + in your dependencies.
In this way you will not be able to replicate your build in the future because you can't know the versions used in your app.
Dynamic versions add nondeterminism to your build and can introduce unexpected behavior changes to your app.
To check Newer Library Versions Available you can use a lint check:
Go to Settings > Editor > Inspections > "Newer Library Versions Available"
Enable the Newer Library Versions Available inspection
Go to Analyze > "Run Inspection By Name" and search for Newer Library Versions Available
You will launch a link check
new version downloads when You create a new build. There is nothing changes in it before You create a new one.
+ here known as dynamic dependencies.
Simply + will use the latest or updated dependency but Using dynamic dependencies (for example, com.localytics.android:library:3.8+) can cause unexpected version updates and regression incompatibilities as suggested by google docs
Pros
Stay updated
Manually updating dependencies can be tedious
Cons
Can break your current code flow due to changes in lib code
Usually there can be some bug found in the new releases so be ready to face unexpected behavior or crash
Conclusion : As advised by google always specify the library version check under Adding Support Libraries
I am making an Android app with Wear capabilities.
I want to share some code between the wearable and handheld modules. Specifically, I want to share communication code that uses Google Play Services classes, e.g. com.google.android.gms.common.api.GoogleApiClient.
The obvious way to do this is to have a module (I called it common) and add a dependency to it in both the handheld and the wearable modules.
Since this common module uses Play Services, I need to make it depend on com.google.android.gms:play-services.
I was not sure what to put for the version number - the official documentation here says to use 5.0.77, but that does not work, as the latest SDK does not have this version anywhere, instead it comes with 5.0.89 and 5.2.08.
If I use 5.0.89, the Wearable app does not work, with this error: Google Play services out of date. Requires 5089000 but found 5077534. The version on the watch is older than the one I used to compile.
Instead of depending on com.google.android.gms:play-services the common module could depend on com.google.android.gms:play-services-wearable but then there is a conflict when building because the handheld module depends on com.google.android.gms:play-services, and these two artefacts use the same package name (com.google.android.gms), and so the gradle build fails.
What's the solution?
.
EDIT after discussing a bit and to make my question clearer.
To be able to use communication APIs in my common module I have two choices:
Make common depend on com.google.android.gms:play-services
Make common depend on com.google.android.gms:play-services-wear
⇒ Solution 1 does not work because the version available (5.0.89) for development is more recent than the one on the watch (5.0.77).
⇒ Solution 2 does not work because the handheld module already depends on com.google.android.gms:play-services, which conflicts with com.google.android.gms:play-services-wear.
I bumped into the same problem a few days ago. My shared module depended on com.google.android.gms:play-services as well, so Gradle refused to build and kept nagging at me:
Error: more than one library with package name 'com.google.android.gms
I added this line to my mobile project's gradle file and the error disappeared magically:
compile(project(':sharedModule')) {
transitive = false
}
Take a look here: https://github.com/tajchert/SWear_Weather
I had created common project that is shared between mobile and wear, and contains my constants. Remember to set there dummy manifest file and:
apply plugin: 'com.android.library' in build.gradle file.
I had also encountered problem with play-services version - I had solved it by using
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.support:wearable:+'
instead of specifying particular version - to be honest it should be separete question - as it is out of scope of previous (sharing code between projects).
It is possible to need invalidate cache/restart after changing - you can/should remove build paths in your projects to get rid of all other versions.