Extract *.jar from *.aar and import; Failed resolution of: Lcom/xxx/xxx/xxx/R$layout when APK running

9.4k views Asked by At

ALL. My project base on android NDK. It use javac, aapt and d8 to compile APK with build.xml. Don't use Android Studio and build.gradle.

I want to use some third party sdk. All sdk is *.aar files.

I decompress *.aar to *.jar; and import *.jar, res,assert and all files to our project. Some *.jar can work normal, but some can't.

It have follow error. java.lang.NoClassDefFoundError: Failed resolution of: Lcom/thirdsdk/thirdsdkui/R$layout;

From above information, It seem that the third sdk class use R.layout itself com.thirdsdk.thirdsdkui.R.layout when apk running, not my project package class name R.layout.

Some document tell me, if want it work when use *.jar.

So the third sdk need use follow code: int layoutId = getResources().getIdentifier("thirdsdk_layout_name", "layout", getPackageName()); setContentView(layoutId);

if follow this, so it error. setContentView(R.layout.thirdsdk_layout_name);

Who have any suggestion for me to resolve it.

Thanks!

1、I try to find a method to import *aar file wuth ant build.xml. But can't find it.

2、I check dx or d8 multidex, i think it work normally.

3、I try to add R.class; R$layout.class for com.thirdsdk.thirdsdkui and repackaging a jar, it error when D8 compile step. It show only one R.class in project.

0

There are 0 answers