如何将库导入android studio? (Android manifestmerger文件)

时间:2015-06-30 09:40:12

标签: android eclipse android-studio

我知道这听起来很容易,但android工作室正在吃掉我的大脑。我知道如何将当前项目导入myProject非常容易地导入ADT。但我很快就知道,对adt的支持很快就会结束。所以我决定改用Android工作室。我在我的项目中使用以下库

  1. 共享
  2. ActionBarSherlock
  3. AndroidImageChacheMaster
  4. SlidingMenuMaster
  5. 我尝试导入项目myProject。

    查看其Project.Properties文件

    # 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
    

    当我尝试导入它时,A.S告诉我不可恢复的错误,我按照android studio的指示粘贴了库文件夹。

    该项目已成功导入

    但是在日志中有两个错误应用

    /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
    

    请帮助这里有什么问题?

    现在我的项目结构是

    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
    

    这是我的gradle文件

    的build.gradle(项目: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(模块:actionbarsherlock)

     apply plugin: 'java'
    

    的build.gradle(模块: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(模块:公地)

    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(模块: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(模块: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'
    }
    

1 个答案:

答案 0 :(得分:2)

如果您已将Sherlock添加为AAR dep,如

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

你可以删除

来自compile project(':actionbarsherlocklibrary')

include ':sherlock'settings.gradle行,然后是项目中的相关文件夹。

您的targetSdkVersion也可以与compileSdkVersion相同。