- Как получить номер сборки/версии вашего приложения для Android?
- ОТВЕТЫ
- Ответ 1
- Ответ 2
- Ответ 3
- Ответ 4
- Ответ 5
- Использование Gradle и BuildConfig
- Получение VERSION_NAME из BuildConfig
- Возвращает ли пустая строка для VERSION_NAME?
- Удаление versionName и versionCode из AndroidManifest.xml
- Ответ 6
- Ответ 7
- Ответ 8
- Ответ 9
- Ответ 10
- Ответ 11
- Ответ 12
- Ответ 13
- Ответ 14
- Ответ 15
- Ответ 16
- Ответ 17
- Ответ 18
- Ответ 19
- Нет, вам не нужно ничего делать с AndroidManifest.xml
- Ответ 20
- Ответ 21
- Ответ 22
- Here’s how to find what Android version and build number you have
- What is the most recent Android version?
- How do you find your version of Android?
- Android Basics : How to Tell What Android Version & Build Number You Have
- Step 1: Open the ‘About Phone’ Menu
- Step 2: View Your Android Version & Build Number
- Manage your Android app’s versionCode & versionName with Gradle
- Don’t repeat yourself. Specify app version metadata just once.
- Define individual components of the version number.
- Compute values for versionCode and versionName.
- Generate a string resource.
- Identify your debug releases.
- Check your generated AndroidManifest.xml.
- Show the version in your About screen.
- Tek Eye
- Android Versions by Name, Number, Availability and API Level
- List of Android Versions and Their Names, API Level and Dates
- Do you have a question or comment about this article?
Как получить номер сборки/версии вашего приложения для Android?
Мне нужно выяснить, как получить или сделать номер сборки для моего приложения Android. Мне нужно, чтобы номер сборки отображался в пользовательском интерфейсе.
Нужно ли что-то делать с AndroidManifest.xml ?
ОТВЕТЫ
Ответ 1
И вы можете получить код версии с помощью этого
Ответ 2
Если вы используете плагин Gradle/Android Studio, от версии 0.7.0, код версии и имя версии доступны статически в BuildConfig , Убедитесь, что вы импортируете пакет приложений, а не другой BuildConfig :
Не требуется контекстный объект!
Также не забудьте указать их в файле build.gradle вместо AndroidManifest.xml .
Ответ 3
Немного короче, если вам просто нужно имя версии.
Ответ 4
Есть две части, которые вам нужны: Android: версия Код Android: версия Имя
versionCode — это число, и каждая версия приложения, которую вы отправляете в Маркет, должна иметь больший номер, чем последняя.
VersionName — это строка, которая может быть любой, какой вы хотите. Здесь вы определяете свое приложение как «1.0», «2.5» или «2 Alpha EXTREME!» или что угодно.
Ответ 5
Использование Gradle и BuildConfig
Получение VERSION_NAME из BuildConfig
Да, теперь это легко.
Возвращает ли пустая строка для VERSION_NAME?
Если вы получаете пустую строку для BuildConfig.VERSION_NAME , то читайте дальше.
Я продолжал получать пустую строку для BuildConfig.VERSION_NAME , потому что я не устанавливал versionName в файле сборки Grade (я перенес из ANT в Gradle). Итак, вот инструкции по обеспечению установки VERSION_NAME с помощью Gradle.
build.gradle
Примечание: это от мастерски Jake Wharton.
Удаление versionName и versionCode из AndroidManifest.xml
И поскольку теперь вы установили versionName и versionCode в файл build.gradle , вы также можете удалить их из своего файла AndroidManifest.xml , если они есть.
Ответ 6
Я не вижу необходимости получать его от менеджера пакетов
Ответ 7
Вот чистое решение, основанное на решении scottyab (отредактированное Xavi). Он показывает, как сначала получить контекст, если он не предоставлен вашим методом. Кроме того, он использует несколько строк вместо вызова нескольких методов на строку. Это облегчает вам задачу отладки вашего приложения.
Теперь, когда вы получили имя версии в String myVersionName , вы можете установить его в TextView или все, что вам нравится.
Ответ 8
Используйте класс BuildConfig
Ответ 9
Если вы используете PhoneGap, создайте собственный плагин PhoneGap:
Создайте новый класс в своем приложении:
В plugins.xml добавьте следующую строку:
В deviceready event добавьте следующий код:
Затем вы можете получить атрибут versionName, выполнив:
Ответ 10
Очень простой способ:
Ответ 11
Вот простой способ получить название версии и код версии
Ответ 12
Для пользователей xamarin используйте этот код, чтобы получить имя и код версии
1) Название версии:
Ответ 13
Получить код сборки, который используется для идентификации apk по его коду версии. Код версии используется для определения фактической конфигурации сборки во время обновления базы данных, публикации и т.д.
int versionCode = BuildConfig.VERSION_CODE;
Имя версии используется для ознакомления пользователей с разработчиками последовательности Developmemt. Вы можете добавить любое название версии по своему желанию.
String versionName = BuildConfig.VERSION_NAME;
Ответ 14
Если вы хотите использовать его в xml, добавьте строку ниже в файл gradle:
И затем используйте его на вашем xml следующим образом:
Ответ 15
Всегда делайте это с блоком try catch :
Ответ 16
Вот способ получения кода версии:
Ответ 17
У меня есть SOLVE this, используя класс предпочтений.
Ответ 18
Есть несколько способов получить versionCode и versionName программно.
- Получить версию из PackageManager . Это лучший способ для большинства случаев.
- Получите его из сгенерированного BuildConfig.java . Но обратите внимание, что если вы получите доступ к этим значениям в библиотеке, она вернет версию библиотеки, а не приложения, использующие эту библиотеку. Так что используйте только в небиблиотечных проектах!
Есть некоторые детали, кроме использования второго способа в проекте библиотеки. В новом плагине Android Gradle (3.0. 0+) некоторые функциональные возможности удалены. Итак, на данный момент, т.е. установка разных версий для разных вкусов работает некорректно.
Код выше будет правильно установить значение в BuildConfig , но от PackageManager вы получите 0 и null , если вы не установили версию в по default конфигурации. Таким образом, ваше приложение будет иметь код 0 версии на устройстве.
Существует обходной путь — установите версию для выходного файла apk вручную:
Ответ 19
Нет, вам не нужно ничего делать с AndroidManifest.xml
Как правило, название и код версии вашего приложения находятся в файле gradle уровня приложения под тегом defaultConfig:
Примечание. Если вы хотите загрузить приложение в PlayStore, можно указать любое имя в качестве имени версии, но код версии должен отличаться от кода текущей версии, если это приложение уже находится в Play Store.
Просто используйте следующий фрагмент кода, чтобы получить код версии и название версии из любой точки вашего приложения:
Ответ 20
для Api 28 PackageInfo.versionCode устарел, поэтому используйте следующий код:
Ответ 21
Этот код упоминался выше, но здесь он снова включен. Вам нужен блок try/catch, потому что он может вызывать «NameNotFoundException».
Надеюсь, это упростит для кого-то дорогу.:)
Ответ 22
Кому-то, кому нужна информация о BuildConfig для пользовательского интерфейса приложения, однако, хочет использовать эту информацию для настройки конфигурации задания CI или других, таких как я.
В вашем каталоге проектов автоматически создается файл BuildConfig.java, пока вы успешно строите проект.
Разделите информацию, необходимую для python script или других инструментов. Вот пример:
Пожалуйста, извините мои ограниченные возможности английского языка, но надеюсь, что это поможет.
Источник
Here’s how to find what Android version and build number you have
We have a great set of update guides here at Android Authority that are sure to keep you on the newest Android build. However, they’re only beneficial if you know what version you’re currently running. Luckily for you, this information isn’t all that hard to track down. Here’s how to find out what Android version and build number your device is running.
Luckily for you, the process of tracking down your Android version doesn’t really change based on your phone. Almost all OEMs tuck the information away in the same place, so let’s get searching.
What is the most recent Android version?
Before we get into finding your Android version, you may as well know how you stack up. Right now, the most recent release is Android 11, which dropped in September 2020. The first phones to make the switch were — unsurprisingly — Google’s own Pixel devices. The rollout has greatly expanded in the months since, and you can check your place in the timeline below.
Android 12 is the next update in the pipeline, though we’ve only seen developer previews thus far. If you really want to stay ahead of the curve, you can download it yourself and check out the newest changes.
How do you find your version of Android?
Now that you know where the latest devices sit, let’s find out where your Android device is. The process is straightforward, and it involves hopping into your settings app. Once you open it, follow these steps:
- Scroll to the bottom of your settings app and locate About phone.
- Enter the About phone section.
- Look for an additional submenu for software information, or you may see a section labeled Android version. Enter this section of your menu.
You should now be able to check your Android version as well as the build number. Your phone may store its security update information and Android skin version information in the same location. While you’re in the settings menu, it might be a great time to see if you have a fresh software update waiting for you.
There you go, everything you need to know about tracking down your Android version. We’ll be sure to update this page with new information if there’s an even easier way to find your version, or Android 12 officially rolls out.
Источник
Android Basics : How to Tell What Android Version & Build Number You Have
A lot of times, you’ll come across an app, a game, or even a cool root mod that requires a certain Android version. The description will say Android 4.3 or higher required, or something to that extent, but not much help is offered beyond that. So to clear things up a bit, I’ll show you how to easily find your device’s Android version or build number below.
Step 1: Open the ‘About Phone’ Menu
Finding your device’s build number or Android version is incredibly easy. To start, open the Settings app that you’ll find in your app drawer, or via the Notification panel. From here, scroll down to the bottom of this menu, then select the «About phone» or «About tablet» entry.
Step 2: View Your Android Version & Build Number
In the About phone/tablet menu, you should find your device’s Android version listed about 7 or 8 entries down. Scroll down to the bottom of this same menu, and the build number will be listed as the final entry—pretty simple, right?
What app, game, or mod were you installing that sparked your visit to this guide? Let us know in the comment section below, or drop us a line on Android Hacks’ Facebook or Twitter, or on Gadget Hacks’ Facebook, Google+, or Twitter.
Keep Your Connection Secure Without a Monthly Bill. Get a lifetime subscription to VPN Unlimited for all your devices with a one-time purchase from the new Gadget Hacks Shop, and watch Hulu or Netflix without regional restrictions, increase security when browsing on public networks, and more.
Источник
Manage your Android app’s versionCode & versionName with Gradle
Don’t repeat yourself. Specify app version metadata just once.
Dec 28, 2015 · 3 min read
Gradle, which is now Android Studio’s default and recommended build system, can help you automate many tasks that other developers might be doing manually.
As you know, every Android app must declare an app’s versionCode (a monotoni c ally increasing integer for each version of the app), and versionName (a text description which can really be anything, but is usually a human-readable version string of the form x.y.z (major version, minor version, patch level). An app’s versionName is usually shown within the app in the About screen, and in other places, such as when sending a bug report. Here’s how you can specify everything in exactly one place and use it everywhere needed.
Define individual components of the version number.
Start off with defining individual components of the version number—major version, minor version and patch level—as separate Gradle variables. This is the one place you’d update the numbers for every version you release.
Compute values for versionCode and versionName.
Then have Gradle compute the versionCode from these three components as a place-value-based number. The versionName is a straightforward string concatenation of the three components.
This will, for example, assign a version code of 20401 for an app with version 2.4.1. That gives you the possibility of 100 minor versions for every major version, and 100 patch levels for every minor version. Seems enough, right?
Generate a string resource.
Next, have Gradle generate a string resource for you automatically, which you can use in your about app’s XML layouts & Java code (as @string/app_version & getResources().getString(R.string.app_version) respectively).
Identify your debug releases.
The code snippet above adds “.debug” to the versionName of all debug releases, so if you see one of these in your logs, you’ll know this wasn’t a release that your users saw — phew! The resource value isn’t automatically updated when we add a versionNameSuffix, so we handle that separately for the debug build type.
Check your generated AndroidManifest.xml.
Now if you look at your generated AndroidManifest.xml, you’ll see that it has the correct auto-generated versionCode and versionName. Note, this is under the build/ directory, not the one in your app/ directory.
Show the version in your About screen.
If you use a Preference-based About screen, simply use the generated string as the preference value.
Источник
Tek Eye
The table in this article lists all the different versions of Android, starting with the earliest Application Programming Interface (API) level to the latest API level. Thus the list is from the oldest Android versions to the latest.
Android Versions by Name, Number, Availability and API Level
Each version of Android is given a code name. The code name is traditionally the name of a dessert, cake or sweet, e.g, Gingerbread, Froyo, Jelly Bean, etc. — as the sugar laden picture below shows. The table that follows lists the code names, version numbers, first release date and Application Programming Interface (API) versions, along with the equivalent Software Development Kit (SDK) constants (Build.VERSION_CODES). The Android version number on a device is normally found in the settings. Select Settings, then About Phone or About Device and look at the Firmware Version or Android Version entry.
List of Android Versions and Their Names, API Level and Dates
Name | Version | Available | API | VERSION_CODES |
---|---|---|---|---|
N/A | 1.0 | October 2008 | 1 | BASE |
N/A | 1.1 | February 2009 | 2 | BASE_1_1 |
Cupcake | 1.5 | May 2009 | 3 | CUPCAKE |
Donut | 1.6 | September 2009 | 4 | DONUT |
Eclair | 2.0 | November 2009 | 5 | ECLAIR |
Eclair | 2.0.1 | December 2009 | 6 | ECLAIR_0_1 |
Eclair | 2.1 | January 2010 | 7 | ECLAIR_MR1 |
Froyo | 2.2 to 2.2.3 | June 2010 | 8 | FROYO |
Gingerbread | 2.3 to 2.3.2 | November 2010 | 9 | GINGERBREAD |
Gingerbread | 2.3.3 to 2.3.7 | February 2011 | 10 | GINGERBREAD_MR1 |
Honeycomb | 3.0 | February 2011 | 11 | HONEYCOMB |
Honeycomb | 3.1 | May 2011 | 12 | HONEYCOMB_MR1 |
Honeycomb | 3.2 to 3.2.6 | June 2011 | 13 | HONEYCOMB_MR2 |
Ice Cream Sandwich | 4.0.1 to 4.0.2 | October 2011 | 14 | ICE_CREAM_SANDWICH |
Ice Cream Sandwich | 4.0.3 to 4.0.4 | December 2011 | 15 | ICE_CREAM_SANDWICH_MR1 |
Jelly Bean | 4.1 to 4.1.1 | July 2012 | 16 | JELLY_BEAN |
Jelly Bean | 4.2 to 4.2.2 | November 2012 | 17 | JELLY_BEAN_MR1 |
Jelly Bean | 4.3 | July 2013 | 18 | JELLY_BEAN_MR2 |
Kit Kat | 4.4 to 4.4.4 | October 2013 | 19 | KITKAT |
Kit Kat | 4.4W to 4.4W.2 | June 2014 | 20 | KITKAT_WATCH |
Lollipop | 5.0 to 5.0.2 | November 2014 | 21 | LOLLIPOP |
Lollipop | 5.1 to 5.1.1 | March 2015 | 22 | LOLLIPOP_MR1 |
Marshmallow | 6.0 to 6.0.1 | October 2015 | 23 | M |
Nougat | 7.0 | August 2016 | 24 | N |
Nougat | 7.1 to 7.1.2 | October 2016 | 25 | N_MR1 |
Oreo | 8.0.0 | August 2017 | 26 | O |
Oreo | 8.1.0 | December 2017 | 27 | O_MR1 |
The above table was derived from the following sources (note that some release dates are derived from the Android developers documentation, the actual SDK availability may have been a little earlier, see the Wikipedia article):
When programming an App the API level is used to determine whether specific Android features are present or not. The API level can be read in versions prior to Donut (Cupcake, 1.1 and 1.0) using:
int APILevel = Integer.parseInt(Build.VERSION.SDK);
And from Donut onwards using:
int APILevel = Build.VERSION.SDK_INT;
(Build.VERSION.SDK is deprecated, i.e. it will be removed from the API at some future release).
When using functionality from a later API, but the App needs to support earlier Android versions, wrap the newer functionality in a separate class. Then check the API level before instantiating the class to prevent a VerifyError exception from occurring. See the article Support Multiple API Versions in Android.
Author: Daniel S. Fowler Published: 2012-05-25 Updated: 2017-01-08
Do you have a question or comment about this article?
(Alternatively, use the email address at the bottom of the web page.)
↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.
Free Android Projects and Samples:
Источник