Создайте библиотеку AAR из кода Android в Android Studio.Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Создайте библиотеку AAR из кода Android в Android Studio.

Сообщение Anonymous »


I have an android project that I want to convert into an .aar library. Inside this project, I am using some google libraries as well as my own SDK library as an aar. Here is the build.gradle below.

I made changes to the last two lines by replacing implementation with compileOnly. The code compiles successfully, but when I generate the .aar file, it doesn't include the Google library. So I had issues when trying to use the library from the generated .aar.

How can I modify the project to generate an .aar library that includes the Google library but excludes my SDK library? My intention is to create a separate .aar file for this project and include it as a plugin alongside with my SDK.
plugins { //id 'com.android.application' id 'com.android.library' } android { namespace 'com.example.sample' compileSdk 34 defaultConfig { //applicationId "com.example.sample" //remove for library minSdk 24 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Google library compileOnly 'com.google.somelibrary:1.0.0' //should be included in aar compileOnly files('libs/mysdk.aar') //should NOT be included in aar }

Источник: https://stackoverflow.com/questions/780 ... oid-studio
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»