Coder Social home page Coder Social logo

Comments (6)

TongWeiLe avatar TongWeiLe commented on May 30, 2024

feature模块编译时R文件只从当前模块里面找,这个改当项目缺失比较恶心了

from qigsaw.

Xiaojuanmao avatar Xiaojuanmao commented on May 30, 2024

除了这个问题之外,你可能还会遇到 feature module单独依赖的 library module在引用宿主资源时候,能编译过但会触发运行时崩溃。这两种问题都能通过改R文件路径来解决。
除了改为全路径外,还可以从生成完的R文件下手,有两种策略:

  1. 第一种是将 feature module 里生成的所有 R.java 类都继承 base module里面的 packageName/R.java 类
  2. 第二种是手动将 base module里的 packageName/R.java 文件和 feature module 目录下所有生成的R文件全部合并

from qigsaw.

PengZeHai avatar PengZeHai commented on May 30, 2024

除了这个问题之外,你可能还会遇到 feature module单独依赖的 library module在引用宿主资源时候,能编译过但会触发运行时崩溃。这两种问题都能通过改R文件路径来解决。
除了改为全路径外,还可以从生成完的R文件下手,有两种策略:

  1. 第一种是将 feature module 里生成的所有 R.java 类都继承 base module里面的 packageName/R.java 类
  2. 第二种是手动将 base module里的 packageName/R.java 文件和 feature module 目录下所有生成的R文件全部合并

==================================================
这个方案在gradle 3.4的时候可行,但在gradle 3.6后,没有R.java这个中间产物了,会直接生成R.jar,这个时候有什么好的策略吗

from qigsaw.

PengZeHai avatar PengZeHai commented on May 30, 2024

对于没有R.java直接生成R.jar的编译,这边尝试着修改字节码,移除base module的final,让feature module R.class继承base R.class。
测试可行

from qigsaw.

hf529270451 avatar hf529270451 commented on May 30, 2024

对于没有R.java直接生成R.jar的编译,这边尝试着修改字节码,移除base module的final,让feature module R.class继承base R.class。
测试可行

请问具体怎么实现呢,我在feature module里面 用asm让 feature modue的R继承了base module的R 但是编译期间还是提示找不到符号

from qigsaw.

PengZeHai avatar PengZeHai commented on May 30, 2024

对于没有R.java直接生成R.jar的编译,这边尝试着修改字节码,移除base module的final,让feature module R.class继承base R.class。
测试可行

请问具体怎么实现呢,我在feature module里面 用asm让 feature modue的R继承了base module的R 但是编译期间还是提示找不到符号

用ASM也可以,我是用Javassist,添加个修改R.jar的task,对于base模块,先解压原本的R.jar,然后移除class的final,不然没法继承,再重新打包成R.jar,替换。对于feature模块,就直接修改为继承base的R就好

from qigsaw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.