Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transitive dependency with Runtime scope are included in fat-aar #15

Closed
mayankm786 opened this issue Jun 20, 2019 · 8 comments
Closed

Comments

@mayankm786
Copy link

Hi,

Firstly, thank you for the plugin.

There seems to be a bug where it is including transitive dependencies in final artifact when I have a custom artifact with pom file.

Reference artifact in build.gradle

// aar dependency 
embed 'com.custom.aar:0.0.1' 
compileOnly 'com.custom.aar:0.0.1' 

pom file (partial) for the artifact

    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-core</artifactId>
      <version>1.1.1</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-android</artifactId>
      <version>1.1.1</version>
      <scope>runtime</scope>
    </dependency>

My understanding is any dependency with runtime scope should not be included in final artifact?

@kezong
Copy link
Owner

kezong commented Jun 21, 2019

https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

  • provided
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
  • runtime
    This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.

I think dependency with runtime scope should included in final artifact.
If dependency with provided scope, maybe should not be included in final artifact.

@mayankm786
Copy link
Author

I think dependency with runtime scope should included in final artifact.

That would make sense when apk is build using that aar.

However in this case i.e. fat-aar (aar -> aar) won't it be increasing the artifact size?
Also inclusion of runtime dependency in my project is causing manifest merge issue while building an apk using the fat-aar.

<provider
            android:name="android.arch.lifecycle.ProcessLifecycleOwnerInitializer"
            android:authorities="fataar.myproject.lifecycle-trojan"
            android:exported="false"
            android:multiprocess="true" />

@kezong
Copy link
Owner

kezong commented Jun 24, 2019

If you want to runtime dependency not be included in final artifact, you can try add exclude keyword in embed, like this:

embed('com.facebook.fresco:fresco:1.11.0') {
    exclude(group:'com.facebook.soloader', module:'soloader')
}

@mayankm786
Copy link
Author

Cool thanks, I was able to exclude them.

Have you tried plugin when one of modules have resources under /raw? I get following error on launching the app consuming fat-aar.

    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/myproject/R$raw;

Interestingly, I see my resources in fat-aar with mapping in R.txt.

@kezong
Copy link
Owner

kezong commented Jun 26, 2019

Yes, fat-aar support raw merge.
You can unzip the aar file, see if there is a file under ‘res/raw’, and if there is an index for the raw in ‘libs/r-classes.jar’

If you still can't solve it, you can send a simple demo to my email.

@mayankm786
Copy link
Author

@kezong Thanks, had some issues during the build on my end.

Have you seen following error?

java.lang.NoSuchFieldError: No static field tooltip of type I in class Lfataar/myrpojectR$layout; 
or its superclasses (declaration of 'fataar.myproject.R$layout' 
appears in /data/app/sample.debug-fwK3uOrj6RNd_YHYB3yqhg==/base.apk)
        at mymodule.R$layout.<clinit>(R.java:1262)

It happens while doing setContentView(R.layout.mylayout)
On debugging it seems no layout are available in this activity.
Most likely it could be an issue due to complex module structure on my end. Any insights will be very useful :)

@kezong
Copy link
Owner

kezong commented Jul 1, 2019

Check the mylayout file and the View inside, and check whether there are multiple mylayout in your project.

@mayankm786
Copy link
Author

@kezong I'm able to reproduce the issue using your sample app - I have created a new ticket #19

Feel free to close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants