Создайте библиотеку AAR из кода Android в Android Studio. ⇐ Android
-
Anonymous
Создайте библиотеку AAR из кода Android в Android Studio.
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
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
Мобильная версия