heap size issue in android studio - android

I have the following issue when run my application using android studio
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 5120 MB.
To do this set org.gradle.jvmargs=-Xmx5120M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
:_4SaleApp:validateDebugSigning
:_4SaleApp:packageDebug
:_4SaleApp:zipalignDebug
:_4SaleApp:fullDebugBuildInfoGenerator
:_4SaleApp:assembleDebug
can any one tell me how to solve this problem ?
EDIT
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.mutualmobile.gradle.plugins:dexinfo:0.1.2'
}
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.forsale.forsale"
minSdkVersion 15
targetSdkVersion 15
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'lib/armeabi-v7a/libblasV8.so'
}
dexOptions {
incremental true
javaMaxHeapSize "10g"
}
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDirs = ['libs']
}
}
productFlavors {
}
/*lintOptions {
checkReleaseBuilds false
abortOnError false
}*/
}
repositories {
jcenter()
maven {
url 'https://zendesk.artifactoryonline.com/zendesk/repo/'
}
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
maven {
url "https://jitpack.io"
}
maven {
url "http://appboy.github.io/appboy-android-sdk/sdk"
}
maven {
url 'https://zendesk.artifactoryonline.com/zendesk/repo'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':gestureimageview')
compile project(':ffmpeg4android_lib')
compile 'com.android.support:multidex:1.0.0'
compile files('libs/universal-image-loader-1.9.5.jar')
compile files('libs/android-hipmob-2.9.8.jar')
compile files('libs/HockeySDK-3.5.0.jar')
compile files('libs/httpclient-4.3.jar')
compile files('libs/httpcore-4.3.jar')
compile files('libs/libphonenumber-5.2v1.5.jar')
compile files('libs/NineOldAndroid-2.4.0.jar')
compile files('libs/org.apache.commons.io.jar')
compile files('libs/zbar.jar')
compile files('libs/quickblox-android-sdk-core-2.5.jar')
compile files('libs/quickblox-android-sdk-chat-2.5.jar')
compile files('libs/quickblox-android-sdk-content-2.5.jar')
compile files('libs/quickblox-android-sdk-messages-2.5.jar')
compile files('libs/renderscript-v8.jar')
compile('com.appboy:android-sdk-ui:1.11.2') {
exclude group: 'com.android.support', module: 'multidex'
}
compile group: 'com.zendesk', name: 'sdk', version: '1.6.0.1'
compile 'com.zopim.android:sdk:1.1.0'
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.github.jaydeepw:poly-picker:v1.0.22'
compile 'com.github.bmelnychuk:atv:1.2.+'
compile 'com.wdullaer:materialdatetimepicker:2.0.2'
compile 'com.danikula:videocache:2.3.4'
compile 'com.instabug.library:instabug:2.+'
//compile 'com.google.android.gms:play-services:8.3.0'
//compile 'com.google.android.gms:play-services-ads:8.3.0'
//compile 'com.google.android.gms:play-services-auth:8.3.0'
//compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.android.support:support-v4:23.2.1'
}

Look my ScreenShot and add this line :
On build.gradle() add
android {
...
dexOptions {
javaMaxHeapSize "3g"
}
..
}
And on gradle.properties add
org.gradle.jvmargs=-Xmx5120M

Related

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. with release

When i generate release build then i got this error
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/arch/core/internal/SafeIterableMap$ListIterator.class
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.23.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.hatchapps.multimedia"
minSdkVersion 16
targetSdkVersion 26
versionCode 17
multiDexEnabled = true
versionName "1.0"
// aaptOptions.cruncherEnabled = false
// aaptOptions.useNewCruncher = false
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// minifyEnabled false
multiDexEnabled = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
packagingOptions {
exclude '.readme'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/services/javax.annotation.processing.Processor'
pickFirst 'AndroidManifest.xml'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'eu.inloop:localmessagemanager:0.1.5'
compile 'com.jakewharton:butterknife:8.8.1'
compile 'com.koushikdutta.ion:ion:2.2.1'
compile 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.cocosw:bottomsheet:1.3.0#aar'
compile 'com.zhy:flowlayout-lib:1.0.3'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.3.0'
compile 'com.andkulikov:transitionseverywhere:1.7.4'
compile 'com.master.android:permissionhelper:1.1'
compile 'net.alhazmy13.MediaPicker:libary:2.3.2'
compile 'com.github.jaychang0917:SimpleText:1.2.1'
compile 'com.github.tabassumLatif:ShimmerRecyclerView:0.1.2'
compile 'com.tomergoldst.android:tooltips:1.0.6'
compile 'com.github.Pixplicity:sharp:03c1568d26'
compile 'id.zelory:compressor:2.0.0'
compile 'com.github.danikula:AndroidVideoCache:v2.7.0'
compile ('com.google.firebase:firebase-messaging:11.0.2'){
force = true
}
compile 'com.fenchtose:tooltip:0.1.5'
compile 'com.jsibbold:zoomage:1.1.0'
compile 'at.blogc:expandabletextview:1.0.3'
compile 'com.github.douglasjunior:android-simple-tooltip:0.2.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
compile 'com.oginotihiro:cropview:1.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.wonderkiln:camerakit:0.11.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile('com.android.support:support-v4:26.1.0'){
force = true
}
}
apply plugin: 'com.google.gms.google-services'
and
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
// classpath 'com.google.firebase:firebase-plugins:1.0.5'
classpath 'com.google.gms:google-services:3.0.0'
// classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://plugins.gradle.org/m2/" }
/*maven {
url "https://maven.google.com"
}*/
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Reading the comments, and having this problem myself, the problem seems to stem from a bad thirdparty lib. Perhaps using incompatible gradle or buildtool library.
Problem libs:
com.wonderkiln:camerakit:0.11.0
android.arch.persistence.room
com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer
Others have similar problems with bad libs in their /libs folder.

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.3

when I want to release my project this error happened:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/fasterxml/jackson/databind/AbstractTypeResolver.class
It's my Module Gradle:
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.vesal.servertest"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id : "3d64bedd-f82d-
4ffd-a968-a2f1caac0fc2",
onesignal_google_project_number: "577414806614"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.mikepenz:materialdrawer:5.9.5#aar') {
transitive = true
}
compile('com.github.orangegangsters:lollipin:2.0.0#aar') {
transitive = true
}
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.romainpiel.shimmer:library:1.4.0#aar'
compile 'com.wrapp.floatlabelededittext:library:0.0.6'
compile 'com.github.tibolte:elasticdownload:1.0.+'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.0'
compile 'com.airbnb.android:lottie:2.2.5'
compile 'devlight.io:navigationtabbar:1.2.5'
compile 'com.github.rey5137:material:1.2.4'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
compile 'com.aurelhubert:ahbottomnavigation:2.0.4'
compile 'com.roughike:bottom-bar:2.3.1'
compile 'com.mikepenz:iconics-core:2.9.3#aar'
compile 'com.mikepenz:google-material-typeface:3.0.1.1.original#aar'
compile 'com.mikepenz:material-design-iconic-typeface:2.2.0.3#aar'
compile 'com.mikepenz:fontawesome-typeface:4.7.0.1#aar'
compile 'com.mikepenz:octicons-typeface:3.2.0.3#aar'
compile 'com.mikepenz:meteocons-typeface:1.1.0.3#aar'
compile 'com.mikepenz:community-material-typeface:1.9.32.2#aar'
compile 'com.mikepenz:weather-icons-typeface:2.0.10.3#aar'
compile 'com.mikepenz:typeicons-typeface:2.0.7.3#aar'
compile 'com.mikepenz:entypo-typeface:1.0.0.3#aar'
compile 'com.mikepenz:devicon-typeface:2.0.0.3#aar'
compile 'com.mikepenz:foundation-icons-typeface:3.0.0.3#aar'
compile 'com.mikepenz:ionicons-typeface:2.0.1.3#aar'
compile 'com.mikepenz:pixeden-7-stroke-typeface:1.2.0.1#aar'
compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
compile 'com.pegah.backtory:backtory-android-sdk:0.5.3'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.android.support:design:26.1.0'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
}
and it's my Project Gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
url "https://www.jitpack.io"
url 'https://dl.bintray.com/pegah-backtory/maven/'
}
}
maven { url 'https://maven.google.com' }
maven { url "https://github.com/omadahealth/omada-
nexus/raw/master/release" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
help me Please!!

Gradle error after in include the dependency of Google cloud big query

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class`
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.critinno.herenowfor"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles
getDefaultProguardFile('proguard-android.txt'),
'proguard- rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
res.srcDirs = ['src/main/res', 'src/main/res/drawable']
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'lib/armeabi-v7a/libblasV8.so'
exclude 'com/google/android/gms/ads/AdActivity.class'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.nex3z:flow-layout:0.1.3'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
testCompile 'junit:junit:4.12'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.lorentzos.swipecards:library:1.0.9'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile("com.google.apis:google-api-services-language:
v1beta1-rev5-1.22.0") {
exclude module: 'httpclient'
exclude module: 'jsr305'
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile (group: 'com.google.cloud',
name: 'google-cloud-bigquery', version: '0.17.2-beta'){
exclude group: 'org.json'
exclude group: 'org.apache.httpcomponents'
}
}
apply plugin: 'com.google.gms.google-services'`

com.android.ide.common.process.ProcessExaception: org.gradle.process.internal.ExecException: finished with non-zero exit value 2

i getting this exception whenever i tried to run the project as method count overflow but when i build signed apk it runs fine ..furthermore i enabled proguard for realse so it is proguard which prevents multidex.. i get confused about multidex whether it is good or bad & why it is not showing any error while genrating signed apk .. any help is appriciated..below is my build.gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
repositories {
maven { url "https://jitpack.io" }
}
android {
signingConfigs {
}
compileSdkVersion 23
useLibrary 'org.apache.http.legacy'
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxx.xxxx"
minSdkVersion 15
targetSdkVersion 22
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile(project(':facebook')) {
exclude group: 'com.android.support', module: 'multidex'
}
compile project(':Volley')
compile project(':squarecamera')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
//compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.shamanland:xdroid-toaster:0.0.10'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.android.support:design:23.1.1'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.malinskiy:superrecyclerview:1.1.2'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.2'
compile 'com.github.lecho:hellocharts-library:1.5.5#aar'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compil'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:1.0.0'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'com.klinkerapps:android-chips:1.0.1#aar'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}

How to include .aar dependency into Android library .aar file

I write some library, which has a portion of UI. Also, this library uses another libraries.
I want to provide release .aar to use this portion of UI in any App.
My library has next dependecies:
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile ('com.android.support:recyclerview-v7:22.2.1'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.10.0'
//Http communication, websockets, etc.
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
//Fonts
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
//Unit tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
//Other
compile ('org.apache.commons:commons-lang3:3.4'){
exclude group: 'org.apache.httpcomponents'
}
//Reactive programmnig
compile 'io.reactivex:rxjava:1.0.13'
compile 'io.reactivex:rxandroid:0.25.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
When I built .aar everything is fine, but when I inlude this .aar into another app, I have next problems:
1). ./gradlew clean build
/home/user/projects/MainApp/app/build/intermediates/exploded-aar/com.my.sdk/SDK/0.0.1/res/values/values.xml:78:21-29
: No resource found that matches the given name: attr 'fontPath'.
/home/user/projects/MainApp/app/build/intermediates/exploded-aar/com.my.sdk/SDK/0.0.1/res/values/values.xml:78:21-29
: No resource found that matches the given name: attr 'fontPath'.
/home/user/projects/MainApp/app/build/intermediates/exploded-aar/com.my.sdk/SDK/0.0.1/res/values/values.xml:78:21-29
: No resource found that matches the given name: attr 'fontPath'.
/home/user/projects/MainApp/app/build/intermediates/exploded-aar/com.my.sdk/SDK/0.0.1/res/values/values.xml:78:21-29
: No resource found that matches the given name: attr 'fontPath'.
/home/user/projects/MainApp/app/build/intermediates/exploded-aar/com.my.sdk/SDK/0.0.1/res/values/values.xml:78:21-29
: No resource found that matches the given name: attr 'fontPath'.
/home/user/projects/MainApp/app/build/intermediates/exploded-aar/com.my.sdk/SDK/0.0.1/res/values/values.xml:78:21-29
: No resource found that matches the given name: attr 'fontPath'.
:app:processDebugResources FAILED
Solution is very simple - add to MainApp/app/build.gradle next line:
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
2). When I run MainApp getting this error:
java.lang.NoClassDefFoundError: com.my.sdk.ui.fragment.DialogAppNotInstalledFragment
To solve this I need to add compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.10.0' to MainApp/app/build.gradle.
Same to other dependecies.
In the result I need just copy-paste all my dependecies from my library project to MainApp project.
Is it possible to make library aar contain all necessery dependecies?
build.gradle of library:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
//apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "0.0.1"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
dexOptions {
preDexLibraries = false
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
lintOptions {
abortOnError false
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile ('com.android.support:recyclerview-v7:22.2.1'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.10.0'
//Http communication, websockets, etc.
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
//Fonts
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
//Unit tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
//Other
compile ('org.apache.commons:commons-lang3:3.4'){
exclude group: 'org.apache.httpcomponents'
}
//Reactive programmnig
compile 'io.reactivex:rxjava:1.0.13'
compile 'io.reactivex:rxandroid:0.25.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
}
// To publish to maven local execute "gradle clean build publishToMavenLocal"
// To publish to nexus execute "gradle clean build publish"
android.libraryVariants
publishing {
publications {
maven(MavenPublication) {
artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar"
artifactId = POM_ARTIFACT_ID
groupId = GROUP
version = VERSION_NAME
// Task androidSourcesJar is provided by gradle-mvn-push.gradle
//artifact androidSourcesJar {
// classifier "sources"
//}
}
}
repositories {
maven {
credentials {
username System.getenv('NEXUS_USER_NAME')
password System.getenv('NEXUS_PASSWORD')
}
url "http://my-nexus-url/"
}
}
}
MainApp/app/build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://my-nexus-url/' }
flatDir {
dirs 'libs'
}
}
android {
signingConfigs {
some_config {
keyAlias 'some alias'
keyPassword '741789654uppy'
storeFile file('../my-keystore.jks')
storePassword 'some_password'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.company.app.android"
minSdkVersion 14
targetSdkVersion 23
versionCode 9
versionName "1.0.0"
}
dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.some_config
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile files('libs/StartAppInApp-2.3.1.jar')
// compile files('libs/android-support-v4.jar')
compile files('libs/applovin-sdk-5.2.0.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
//here is my library!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
compile('com.my.sdk:SDK:0.0.1#aar'){
transitive = true;
exclude(group:'android.support', module: 'support-v4')
}
//***********************************************
//Dependecies from library
//***********************************************
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'io.reactivex:rxjava:1.0.13'
compile 'io.reactivex:rxandroid:0.25.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile ('com.android.support:recyclerview-v7:22.2.1'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('org.apache.commons:commons-lang3:3.4'){
exclude group: 'org.apache.httpcomponents'
}
compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.10.0'
//************************************************
}
UPDATE
Generated POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.sdk</groupId>
<artifactId>SDK</artifactId>
<version>0.0.1</version>
<packaging>aar</packaging>
</project>
If anybody have the same problem, you may obtain correct answer here
Result build.gradle is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "0.0.1"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
dexOptions {
preDexLibraries = false
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
lintOptions {
abortOnError false
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile ('com.android.support:recyclerview-v7:22.2.1'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.10.0'
//Http communication, websockets, etc.
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
//Fonts
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
//Unit tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
//Other
compile ('org.apache.commons:commons-lang3:3.4'){
exclude group: 'org.apache.httpcomponents'
}
//Reactive programmnig
compile 'io.reactivex:rxjava:1.0.13'
compile 'io.reactivex:rxandroid:0.25.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
}
// To publish to maven local execute "gradle clean build publishToMavenLocal"
// To publish to nexus execute "gradle clean build publish"
android.libraryVariants
publishing {
publications {
maven(MavenPublication) {
artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar"
artifactId = POM_ARTIFACT_ID
groupId = GROUP
version = VERSION_NAME
pom.withXml {
def depsNode = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each { dep ->
if(dep.name != null && dep.group != null && dep.version != null) {
def depNode = depsNode.appendNode('dependency')
depNode.appendNode('groupId', dep.group)
depNode.appendNode('artifactId', dep.name)
depNode.appendNode('version', dep.version)
//optional add scope
//optional add transitive exclusions
}
}
}
}
}
repositories {
maven {
credentials {
username System.getenv('NEXUS_USER_NAME')
password System.getenv('NEXUS_PASSWORD')
}
url "http://nexus-repository-url/"
}
}
}

Categories

Resources