royliu
V2EX  ›  Android

请教一个 gradle 版本升级导致 aar 打包出现错误的问题

  •  
  •   royliu · Jan 3, 2019 · 11739 views
    This topic created in 2781 days ago, the information mentioned may be changed or developed.
    需要将一个 module 打包成 aar,module libs 目录有第三方提供的 jar 文件,jar 里有一些 xml 配置文件是和 java 文件一个目录编译的。以前用 gradle 版本 2.2.2 进行打包,那些 xml 文件是可以在生成的 xml 文件里找到的。如图:
    https://imgur.com/PwwwKH9
    这两天将 gradle 版本升级到 3.1.2。发现打包时上面那些 xml 文件以及 assets 目录都没有了。如图:
    https://imgur.com/WLwMc0N

    项目中第三方库找不到对应的 xml 会报错。网上找了一圈没有什么头绪,希望有大神能指点一下
    1 replies    2019-01-03 15:24:23 +08:00
    airfling
        1
    airfling  
       Jan 3, 2019
    自己写个 fatJar 的 task,自己打包

    task fatjar(type: Jar) {
    baseName = project.name + '-all'
    from files(sourceSets.main.output.classesDir)
    from files(sourceSets.main.output.resourcesDir)
    from { configurations.compile.collect { zipTree(it) } } {
    exclude "META-INF/*.SF"
    exclude "META-INF/*.DSA"
    exclude "META-INF/*.RSA"
    }
    manifest {
    attributes 'Main-Class': 'com.test.DemoApplication'
    }
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2780 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 00:19 · PVG 08:19 · LAX 17:19 · JFK 20:19
    ♥ Do have faith in what you're doing.