Mukund
Mukund

Reputation: 1105

how to import libraries to android studio? (Android manifestmerger file)

I know this sounds very easy, but android studio is eating my brains out. I know how to import my current project say myProject in to ADT very easily. But I came to know that soon the support for adt will be ending. So i decided to switch to Android studio. I am using the following libraries in my project

  1. Commons
  2. ActionBarSherlock
  3. AndroidImageChacheMaster
  4. SlidingMenuMaster

I tried to import the project myProject.

See its Project.Properties file

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-21
android.library.reference.1=../actionbarsherlocklibrary
android.library.reference.2=../Android-Image-Cache-master
android.library.reference.3=../Commons
android.library.reference.4=../google-play-services_lib
android.library.reference.5=../SlidingMenuMaster

When i tried to import it A.S told me unrecoverable errors and I pasted the library folder as instructed by android studio.

And it project was imported succesfully

but there are two error apparing in the log

/home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/manifests/tmp/manifestMerger2026412193483179673.xml

Error:(5, 5) uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library /home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/AndroidManifest.xml

Error:(5, 5) Execution failed for task ':commenorkingandroid:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library /home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.actionbarsherlock" to force usage

please help what is wrong here?

and now my project structure is

actionbarsherlocklibrary(empty)
myProject(manifests,java,res,aidl,resources,c,assets)
androidimagecachemaster(manifests,java,res)
commenorkingandroid(manifests,java,res) // i havent imported anything with this name
commons(manifests,java,res)
Gradle Scripts
 build.gradle(Project:myProject)
 build.gradle(Module:actionbarsherlock)
 build.gradle(Module:myProject)
 build.gradle(Module:commons)
 build.gradle(Module:androidimagecachemaster)
 build.gradle(Module:commenorkingandroid)

gradle-wrapper.properties
settings.gradle

here are my gradle files

build.gradle(Project:myProject)

// 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:1.2.3'
 }
}

allprojects {
  repositories {
    jcenter()
 }
}

build.gradle(Module:actionbarsherlock)

 apply plugin: 'java'

build.gradle(Module:myProject)

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.five.myApp"
    minSdkVersion 11
    targetSdkVersion 16

    ndk {
        moduleName "cr3engine-3-1-1"
    }
 }

  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
   }
}

dependencies {
compile project(':actionbarsherlocklibrary')
compile project(':androidImageCachemaster')
compile project(':commons')
compile project(':commenorkingandroid')
compile 'com.google.code.gson:gson:2.1'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/commons-io-2.4.jar')
compile files('libs/epublib-core-latest.jar')
compile files('libs/slf4j-android-1.6.1-RC1.jar')
compile files('libs/slf4j-android-1.7.5-7-sources.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/zip4j_1.3.2.jar')
}

build.gradle(Module:commons)

apply plugin: 'com.android.library'

android {
compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion "22.0.1"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 15
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/actionbarsherlock-plugin-maps-4.1.0.jar')
}

build.gradle(Module:androidimagecachemaster)

apply plugin: 'com.android.library'

android {
compileSdkVersion 10
buildToolsVersion "22.0.1"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 16
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/CWAC-AdapterWrapper.jar')
}

build.gradle(Module:commenorkingandroid)

apply plugin: 'com.android.library'

android {
compileSdkVersion 19
buildToolsVersion "22.0.1"

defaultConfig {
    minSdkVersion 5
    targetSdkVersion 17
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.0'
}

Upvotes: 0

Views: 462

Answers (1)

Ye Lin Aung
Ye Lin Aung

Reputation: 11469

If you have added Sherlock as an AAR dep like

compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

you can remove

compile project(':actionbarsherlocklibrary'), include ':sherlock' line from your settings.gradle, then related folder from your project.

And your targetSdkVersion can be the same as your compileSdkVersion as well.

Upvotes: 2

Related Questions