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

Can't resolve resource for child modules #19

Closed
mayankm786 opened this issue Jul 2, 2019 · 9 comments
Closed

Can't resolve resource for child modules #19

mayankm786 opened this issue Jul 2, 2019 · 9 comments

Comments

@mayankm786
Copy link

Steps to reproduce the issue by updating your example app.

  1. Create a library module lib-aar-child-1 and make it a dependency for lib-aar.
  2. Create any activity in lib-aar-chidl-1 that injects some layout file.
  3. Build lib-main
  4. Create an application that consume fat-aar created in step 3
  5. With-in the sample application start activity you created in step 2
  6. Now launch the sample application - it will fail with following error
Process: fataarcom.myapplication, PID: 24168
    java.lang.NoSuchFieldError: No static field notification_media_action of type I in class Lcom/kezong/demo/lib/R$layout; or its superclasses (declaration of 'com.kezong.demo.lib.R$layout' appears in /data/app/fataar.com.myapplication-ak0csAas0a06SfPPK9sGkw==/base.apk!classes2.dex)
        at com.kezong.demo.libaar.child.R$layout.<clinit>(R.java:1018)
@kezong
Copy link
Owner

kezong commented Jul 3, 2019

Following your steps, I can't reproduce the issue.
The layout that I used is simple, like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="vertical">

    <Button
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:text="text" />
</LinearLayout>

What is notification_media_action in your xml?
You can send your complete demo to my email

@mayankm786
Copy link
Author

Will try to send you the demo, meanwhile more information

Generated activity and layout through Android Studio

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

Inside build.gradle for lib-aar

    implementation project(":lib-aar-child1")

Inside build.gradle for lib-main

    embed project(path: ':lib-aar', configuration:'default')
    compileOnly project(path: ':lib-aar')

    embed project(path: ':lib-aar-child1', configuration:'default')

@kezong
Copy link
Owner

kezong commented Jul 4, 2019

I didn't receive your demo.
There's still too little information. I can't reproduce it.
When compiling aar, use assembleRelease, and AAPT checks resources strictly.

@mayankm786
Copy link
Author

@kezong turns out above issue was due to different version of support lib version in fat-aar and sample application

@kezong
Copy link
Owner

kezong commented Jul 8, 2019

Yes, the support lib must be the same version.

@kezong kezong closed this as completed Jul 8, 2019
@oaacelasu
Copy link

Hi I have the same problem :(, what does means "different version of support lib version in fat-aar"

I'm using classpath 'com.kezong:fat-aar:1.1.10' in my buildScript

java.lang.NoSuchFieldError: No static field notification_media_action of type I in class Lcom/paymentez/threedsv2/R$layout; or its superclasses (declaration of 'com.paymentez.threedsv2.R$layout' appears in /data/app/com.paymentez.threedsv2.example-EBinF0yeCgxL3p42GsMqGw==/split_lib_slice_6_apk.apk)
at com.modirum.threedsv2.R$layout.(R.java:1304)
at com.modirum.threedsv2.core.ui.a.k.show(SourceFile:29)
at com.paymentez.threedsv2.example.MainActivity.getSdkInfo(MainActivity.java:146)
at com.paymentez.threedsv2.example.MainActivity.createTransactionAndSdkInfo(MainActivity.java:81)
at com.paymentez.threedsv2.example.MainActivity$1.onClick(MainActivity.java:65)
at android.view.View.performClick(View.java:6608)
at android.view.View.performClickInternal(View.java:6585)
at android.view.View.access$3100(View.java:785)
at android.view.View$PerformClick.run(View.java:25921)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

@kezong
Copy link
Owner

kezong commented Jul 17, 2019

"different version of support lib version in fat-aar" means the support lib version that your application used is best to be the same as the library use. like this:

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

If you use 27.1.1 in your library, 29.0.0 in your application, maybe throw the error.

@mochadwi
Copy link

The recommended way was using resoulutionsStrategy.all to force the support library using the same latest stable version.

@Hasan-rapido
Copy link

Could you please look into the similar issue,
#406

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

5 participants