...

Android shared library что это за программа на Андроид и нужна ли она

What exactly means «shared library» when developing in Java for Android? (`*.jar` or `*.so`)

My first guess was that a *.so (unix) or *.dll (win) is a shared library. At least that is my usage writing code in C. Now the context is developing for Android, which is done in Java->Dalvik style. I have troubles with a perceived ambiguity of the the term shared library there. In java it seems that *.jar files or *.dex files contain the code that is somewhat both, shared and a library. Is there a reference to tell what is meant by shared library ? A very specific problem is that Android developers aapt packaging thing is having the option —shared-lib

—shared-lib Make a shared library resource package that can be loaded by an application at runtime to access the libraries resources. Implies —non-constant-id.

which I have no clue what now is meant by shared library. I am aware that there is this JNI interface and some Android NDK stuff might also have *.so files which might be meant, but I am really not sure.

asked Mar 9, 2016 at 15:18
humanityANDpeace humanityANDpeace
4,360 3 3 gold badges 37 37 silver badges 63 63 bronze badges

1 Answer 1

On Android developers code in Java, the classes he writes are compiled into Java bytecode (bundled in jar along with other classes automatically created during the building process). once created, this bytecode is translated to Dalvik bytecode (.dex) which is included in the application bundle (apk).

In addition to the Java code, application can be programmed using «native libraries» written in C code and compiled with the android-ndk for the device specific architecture, generating .so files (dynamically linked) or .a libraries (linked statically). Normally this is done for performance issues or reusing libraries written in C and avoid porting them to Java. As you said in the question, this binding is done via the JNI library.

These libraries must be included in the application bundle (apk) and loaded at runtime by the application with System.loadLibrary().

answered Mar 9, 2016 at 15:41
Francesc Lordan Francesc Lordan
519 4 4 silver badges 24 24 bronze badges

So do you mean to say that i.e. the aapt packager’s —shared-lib argument has something to do with the native shared libraries? Also you would not refere to a jar file as a library, or would you considering that they might be the origin for imported classes, i.e. they behave like a library *.a file to a native «C-program»?

Mar 9, 2016 at 16:29

Jar files which the application depends on are part of the Java code. Your Java code and its dependencies are converted to Dalvik bytecode (runs in the Dalvik VM). So yes, from the Dalvik point of view, they are liked statically. Shared libraries are compiled for the actual ISA of the mobile so they do not need any VM to run. They are added into to apk file as they are.

Android shared library что это за программа на Андроид и нужна ли она

Иван Осокин

Оцените автора

Добавить комментарий Отменить ответ

Свежие записи

  • Криптовалюты в бизнесе
  • Накрутка жалоб ВК как способ быстро избавиться от конкурентов
  • Где можно приобрести электромотоцикл?
  • Интерактивное телевидение Ростелеком – что это?
  • Польза и необходимость регулярного медицинского осмотра перед возникновением проблем

Вам также может понравиться

В мире современного бизнеса криптовалюты стали неотъемлемой

Продвигать свои услуги, товары и контент можно разными

Хотите купить электромотоцикл в Москве? Не знаете

Интерактивное телевидение стало популярным в наше время

Предварительное и периодическое проведение профосмотра

Мы предлагаем вам удобное и выгодное решение для управления

Дерево-полимерный композит, или ДПК, — это современный

Привлечение внимания к сообществу во ВКонтакте – это

  • Политика конфиденциальности
  • Пользовательское соглашение

​Временно возглавляющий минпром Башкирии Фарит Гильманов (ранее

В городе Салавате планируют открыть производственный

Вы заметили как с момента прихода Динара Халилова началась

При подготовке материала использовались источники:
https://stackoverflow.com/questions/35895571/what-exactly-means-shared-library-when-developing-in-java-for-android-jar
https://siding-rdm.ru/shared-library-chto-eto-za-programma-na-android-nuzhna-li-ona/

Оцените статью