eclipse迁移到android studio

本文介绍了一个复杂的Android项目的构建配置细节,包括Gradle依赖管理、编译选项调整、资源排除及库集成等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

apply plugin: 'com.android.application'

def buildTime() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMdd')
    return "_$formattedDate"
}

dependencies {

    // 在eclipse 中导入了 ['android-support-multidex.jar', 'org.apache.http.legacy.jar'], 因此需要删除。
    compile fileTree(dir: 'libs', include: '*.jar', exclude:['android-support-multidex.jar', 'org.apache.http.legacy.jar'])
    compile project(':androidv4:lib:StggerGrid')
    compile project(':androidv4:lib:ImageSlider:Library')
    compile project(':androidv4:lib:SwipeMenuListView')
    compile project(':androidv4:lib:StickyListHeaders-master:library')
    compile project(':androidv4:lib:Squareup')
    compile project(':androidv4:lib:android-menudrawer-master:menudrawer')
    compile project(':androidv4:lib:Signature')
    compile project(':androidv4:lib:FloatingActionButton-master:library:src:main')
    compile project(':androidv4:lib:HorizontalVariableListView:main')
    compile project(':androidv4:lib:ViewPagerIndicator-master:ViewPagerIndicator_Library')
    compile project(':androidv4:lib:PhotoView-master:library:src:main')
//    compile project(':v7-6.0:appcompat')

    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.android.support:cardview-v7:23.2.1'
    
    // 分包
    compile 'com.android.support:multidex:1.0.0'

    // 状态栏
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'

    // 处理android6.0权限问题
    compile 'com.anthonycr.grant:permissions:1.0'

    // 聊天输入框
    compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.2'
    compile 'com.github.w446108264:AndroidEmoji:1.0.0'
    compile project(':reclib-testemoticons')


    // Required -- JUnit 4 framework
    testCompile 'junit:junit:4.12'
    // Optional -- Mockito framework
    testCompile 'org.mockito:mockito-core:1.10.19'
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            
            // 自动创建时没有这个,需要加上
            jniLibs.srcDirs = ['libs']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23

        // 开启分包 65536
        multiDexEnabled true
    }
    
    // 忽略错误
    lintOptions {
          checkReleaseBuilds false
          // Or, if you prefer, you can continue to check for errors in release builds,
          // but continue the build even when errors are found:
          abortOnError false
    }
    
    // 如果打包过程中,报outofmemory异常,适当增加内存
    dexOptions {
         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'
    }
    
    useLibrary 'org.apache.http.legacy'


//    buildTypes {
//
//    }
//
//    productFlavors {
//        sunyun {}
//        yinman{}
//
//        applicationVariants.all { variant ->
//            variant.outputs.each { output ->
//
//                def newName = variant.baseName.replace("-release", "") + buildTime() + ".apk";
//                output.outputFile = new File("${project.rootDir}/apk/", newName);
//            }
//        }
//    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值