android项目由Gradle 2.2 切换到 3.0的坑_春暖花开_love的博客-程序员秘密

技术标签: android 开发  android3.0  

问题1、运行的时候一直报如下错误

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForApiTestDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
查了很多资料,大概意识是引用重复的库或jar的问题。

然后一遍一遍的检查,发现并没有引用重复的jar包。

最后考虑是不是第三方库引用jar出现的问题,然后就一个一个排查第三方库,最后发现我们用支付用的是

 compile 'com.pingxx:pingpp-alipay:2.1.9' // 使用支付宝时添加
发现这个库有些问题,竟然在里面引用两个版本的支付宝的jar包,果断的换了最新版本,检查了一个这次就引用了一个jar包。重新编译了一下项目,运行成功,问题解决了。

特别注意:引用第三方库在gralde3.0版本是更为严格,要特别注意。


问题2、

AAPT2

AAPT2 将默认启用,如果遇到离奇的问题,可以尝试禁用,只要在 gradle.properties 中加入:

     
      
android.enableAapt2=false

其他:

应用(app)目录下build.gradle(下面 implementation "com.android.support:design:25.4.0" 切换为 project的统一配置)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

    android {
        compileSdkVersion 25
        buildToolsVersion "26.0.2"

        defaultConfig {
            multiDexEnabled true
            applicationId "com.example"
            minSdkVersion 21
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"

            renderscriptTargetApi 23
            renderscriptSupportModeEnabled true

        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
			targetCompatibility JavaVersion.VERSION_1_8
        }
        lintOptions {
            quiet true
            abortOnError false
            ignoreWarnings true
            disable 'InvalidPackage'           //Some libraries have issues with this.
            disable 'OldTargetApi'
            //Lint gives this warning but SDK 20 would be Android L Beta.
            disable 'IconDensities'            //For testing purpose. This is safe to remove.
            disable 'IconMissingDensityFolder' //For testing purpose. This is safe to remove.
        }


        dexOptions {
            javaMaxHeapSize "8G"
        }

        packagingOptions {
            exclude 'LICENSE.txt'
            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/rxjava.properties'
        }

        sourceSets {
            main.java.srcDirs += 'build/generated/source/apt'
        }
    }

    repositories {
        flatDir {
            dirs 'libs'
        }
    }



    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation project(':library_api')
    implementation project(':library_base')
    implementation project(':library_blur_dialog')
    implementation project(':library_countrycodepicker_dialog')
    implementation project(':library_glow_decorator')
    implementation project(':library_icons')
    implementation project(':library_loopvideo')
    implementation project(':library_section_adaper')
    implementation project(':library_taptargetview')
    implementation project(':library_ucrop')
    implementation project(':library_utils')
    implementation project(':library_utils_picasso')
    implementation project(':library_vector_compat')
    implementation project(':library_view_clock')
    implementation project(':library_view_shimmer_recycler')

    implementation "com.google.android.gms:play-services-cast-framework:11.4.2"
    compileOnly 'com.google.android.wearable:wearable:2.0.3'
    implementation 'com.google.android.support:wearable:2.0.3'
    implementation 'com.google.android.exoplayer:exoplayer:r2.4.1'

    implementation "com.android.support:mediarouter-v7:25.4.0"
    implementation "com.android.support:leanback-v17:25.4.0"
    implementation "com.android.support:design:25.4.0"

    implementation "com.android.support:appcompat-v7:25.4.0"
    implementation "com.android.support:support-v4:25.4.0"
    implementation "com.android.support:gridlayout-v7:25.4.0"
    implementation "com.android.support:cardview-v7:25.4.0"
    implementation "com.android.support:recyclerview-v7:25.4.0"
    implementation "com.android.support:preference-v14:25.4.0"

    // rxjava
    implementation  'io.reactivex:rxjava:1.2.9'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'com.github.davidmoten:rxjava-extras:0.8.0.6'

    // square
	implementation  "com.squareup.retrofit2:retrofit:2.1.0",
    implementation  "com.squareup.retrofit2:converter-gson:2.1.0"
    implementation "com.squareup.retrofit2:adapter-rxjava:2.1.0"
    implementation "com.squareup.phrase:phrase:1.1.0"

    implementation "com.squareup.okhttp3:okhttp:3.6.0"
    implementation "com.squareup.okhttp3:logging-interceptor:3.6.0"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:3.6.0"

    // picasso
    implementation  "com.squareup.picasso:picasso:2.5.2"
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

    // dagger
    implementation "com.google.dagger:dagger:2.10"
    annotationProcessor  "com.google.dagger:dagger-compiler:2.10"
    implementation "javax.annotation:jsr250-api:1.0"
    implementation  "javax.inject:javax.inject:1"


    // jake ftw
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    compileOnly 'org.projectlombok:lombok:1.16.16'
    annotationProcessor 'org.projectlombok:lombok:1.16.16'

    // FragmentWithArgs
    implementation   "com.hannesdorfmann.fragmentargs:annotation:3.0.2",
    annotationProcessor "com.hannesdorfmann.fragmentargs:processor:3.0.2",

    implementation "org.parceler:parceler-api:1.1.9",
    annotationProcessor "org.parceler:parceler:1.1.9",
    implementation 'com.hannesdorfmann.fragmentargs:bundler-parceler:3.0.2'

    implementation "com.github.codekidX:storage-chooser:1.0.34"

    implementation 'io.github.yavski:fab-speed-dial:1.0.6'

    implementation('com.crashlytics.sdk.android:crashlytics:[email protected]') {
        transitive = true;
    }

    // intent builder
    implementation         "com.github.marcinmoskala.activitystarter:activitystarter:1.00"
	annotationProcessor  "com.github.marcinmoskala.activitystarter:activitystarter-compiler:1.00"

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'//constraint-layout
    implementation 'org.greenrobot:eventbus:3.0.0'
    //font
    implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
    implementation 'com.github.florent37:expectanim:1.0.6'
    implementation 'com.romandanylyk:pageindicatorview:[email protected]'
    implementation 'com.github.rubensousa:gravitysnaphelper:1.2'
    implementation 'com.flaviofaria:kenburnsview:1.0.7'
    implementation 'com.github.florent37:arclayout:1.0.2'

    implementation 'com.jakewharton.rxbinding:rxbinding:1.0.1'
    implementation 'com.wang.avi:library:2.1.3'
    implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:[email protected]'
    implementation 'com.borax12.materialdaterangepicker:library:1.9'
    implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
    //Location
    implementation "com.google.android.gms:play-services-maps:11.4.2"
    implementation 'pl.charmas.android:android-reactive-location:[email protected]'
    implementation "com.google.android.gms:play-services-location:11.4.2"
    //you can use newer GMS version if you need
    implementation "com.google.android.gms:play-services-places:11.4.2"
    implementation 'com.tbruyelle.rxpermissions:rxpermissions:[email protected]'
    implementation 'commons-validator:commons-validator:1.4.1'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.5.2'
    implementation 'ru.egslava:MaskedEditText:1.0.5'
    implementation 'com.futuremind.recyclerfastscroll:fastscroll:0.2.5'

    implementation "com.google.firebase:firebase-core:11.4.2"


    implementation 'com.labo.kaji:swipeawaydialog:0.1.1'
    implementation 'io.supercharge:shimmerlayout:1.0.1'
    implementation 'hanks.xyz:htextview-library:0.1.5'
    implementation 'com.github.castorflex.smoothprogressbar:library:1.1.0'//progressbar for action bar
    implementation 'io.reactivex:rxjava-math:1.0.0'
    implementation 'jp.wasabeef:picasso-transformations:2.1.2'
    implementation 'com.afollestad.material-dialogs:core:0.9.1.0'
    implementation('com.github.ihsanbal:LoggingInterceptor:2.0.2') {
        exclude group: 'org.json', module: 'json'
    }

}



项目(project)目录下 build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
//        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.meituan.android.walle:plugin:1.1.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
//        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.google.com' }
        maven { url "https://dl.google.com/dl/android/maven2/"}
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


ext {
    targetSdkVersion = 26
    minSdkVersion = 14
    compileSdk = 26
    buildTools = "26.0.2"
    junit = 'junit:junit:4.12'
    recyclerview = 'com.android.support:recyclerview-v7:26.0.2'
    appcompat = 'com.android.support:appcompat-v7:26.0.2'
    design = 'com.android.support:design:26.0.2'
    percent = 'com.android.support:percent:26.0.2'
    glide = 'com.github.bumptech.glide:glide:3.7.0'
    retrofit = 'com.squareup.retrofit:retrofit:1.9.0'
    gson = 'com.google.code.gson:gson:2.8.0'
    okhttp = 'com.squareup.okhttp3:okhttp:3.6.0'
//    converterGson = 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
//    converterJackson = 'com.squareup.retrofit:converter-jackson:1.9.0'
   
    commonsio = 'commons-io:commons-io:2.4'
}



参考资料:

android切换到greale 3.0的官方教程

android 项目使用java8 官方指南

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u013488627/article/details/79205154

智能推荐

Dataguard健康检查_dataguard检查_姚远Oracle ACE的博客-程序员秘密

查询Dataguard的状态:SQL> select d.DB_UNIQUE_NAME,d.open_mode,d.log_mode,d.DATABASE_ROLE,d.PROTECTION_MODE from v$database d;DB_UNIQUE_NAME OPEN_MODE LOG_MODE DATABASE_ROLE PROTECTION_M...

RecSys 2017总结_recsys challenge 2017_傅里叶、的博客-程序员秘密

版权归作者所有,任何形式转载请联系作者。作者:咚咚咚diduan(来自豆瓣)来源:https://www.douban.com/note/662840537/今年的ACM RecSys在美丽的科莫湖畔举办,本文将从会议总览,推荐系统技术与发展趋势,个人观感三个方面介绍本次大会。会议总览今年的RecSys接收26篇long paper(接收率:20.8%),20篇short paper(接收率:16...

服务端编程(零)纲举目张 文章导航_阮菜鸡的博客-程序员秘密

基础学习思路普及服务端的基础知识,具体玩Django框架自制一个 图书管理系统的应用访问 github:或者访问服务器:http://47.112.174.246:3389/catalog/基础篇服务端编程(一)- 背景知识介绍 - Internet 相关概念解析 ISP IP IPv4 域名 DNS 数据包解析服务端编程(二)- 背景知识 - web 客户端 服务...

execute php,php扩展实践zend_execute_ex层获取实参_李博杰的博客-程序员秘密

其实在实现的 php 函数里面是很容易获取到的,参考 php 的 builtin 函数 func_get_args() 就可以知道了。void **p;int arg_count;int i;zend_execute_data *ex = EG(current_execute_data);if (!ex || !ex->function_state.arguments) {RETURN_FA...

【C++】C++写后端程序_c++可以写后端吗_bandaoyu的博客-程序员秘密

c++写后端我司就在做,前端vue,传ajax请求给后端,后端cinatra处理http ajax请求,ormpp数据库建模,nginx托管静态资源,接口请求反向代理给cinatra处理,这两个c++后端库都是headonly的,接口及其简单强力推荐cinatraormpp作者:赵河马链接:https://www.zhihu.com/question/345039462/answe...

helm滚动更新mysql_helm部署mysql_王邺华的博客-程序员秘密

如果您的kubernetes已有了helm,那么部署mysql的步骤可以进一步简化,那些原先需要自己动手配置的deployment和service都已集成在chart中,今天就来实战通过helm部署mysql,并且将之前遇到的问题抛出来给大家参考;环境信息硬件:三台CentOS 7.7服务器kubernetes:1.15helm:2.16.1mysql:关于helmkubernetes环境helm...

随便推点

【JZOJ5336】【NOIP2017提高A组模拟8.24】提米树_5336 提米树_dance_in_the_dark的博客-程序员秘密

DescriptionData ConstraintSolution我们可以用dp解决。设dp[i]表示前i个节点的最优值。我们发现一对节点(x,y)(x的dfs序小于y的dfs序)可以形成相邻叶子当且仅当x处于其lca的儿子u的右链上,y处于lca的儿子v的左链上,且u,v相邻u在v的左方。我们将每一条右链存下,对于每个节点查找其对应右链的答案。这样是O(N^2)的。 我们发现没一个左链上的点顺

Spring Boot Features------2. Externalized Configuration文档翻译(part2)_192.168.2.2_豢龙先生的博客-程序员秘密

2. Externalized Configuration本节将深入讨论Spring Boot的细节。在这里,您可以了解您可能希望使用和自定义的关键特性。SpringApplication类提供了一种方便的方式来引导从main()方法启动的Spring application。在很多情况下,你可以委托给静态的SpringApplication.ru()方法,如下面的例子所示(该主方法位于Spr...

Java面向对象编程(第2版)_学习记录_Bloonow的博客-程序员秘密

《Java面向对象编程(第2版)》孙卫琴 编著文章目录一、介绍(一)平台与开发环境(二)一些知识(三)数组二、类的生命周期(一)类的加载1. 加载2. 连接3. 初始化(二)类加载器1. 根类加载器2. 扩展类加载器3. 系统类加载器4. 创建用户自定义的类加载器(三)类的卸载三、对象的生命周期(一)创建对象(二)垃圾回收(三)对象的强、弱、软、虚引用(四)内部类四、多线程(一)Java线...

图神经网络(GNN) 图与图学习_如果我变成回忆l的博客-程序员秘密

图与图学习一. 图的基本表示方法二. 如何存储图三. 图的类型和性质四.什么是图神经网络?五.有哪些图神经网络?1. 图卷积网络(Graph Convolution Networks,GCNs)2. 基于空间的GCNs方法3. 基于组合的空间GCNs方法4. 图注意力网络(Graph Attention Networks)5. 图自动编码器(Graph Autoencoders)6. 图生成网络(Graph Generative Networks)7. 图时空网络Graph Spatial-Tempora

Java中如何将OutputStream转换为InputStream_weixin_33750452的博客-程序员秘密

如果你曾经使用java IO编程,你会很快碰到这种情况,某个类在OutputStream上创建数据而你需要将它发送给某个需要从输入流读取数据的类。  你很快会被问道,“java中如何将OutputStream转换为InputStream?”  方法一:使用字节数组缓存数据  最简单的方法是用字节数组缓存数据。代码  ByteArrayOu...

public static <T> List<T> asList(T... a) 原型是怎么回事?_javaPie的博客-程序员秘密

public static List asList(T... a) 原型是怎么回事?翻翻java sdk的源代码 发现这个看起来好屌, List 是怎么回事 看起来好像颜文字,一个在哭的List第一个这个token是什么意思呢?为什么不省略,省略了我也知道是返回一个List啊这个姿势怎么学?添加评论 分享

推荐文章

热门文章

相关标签