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

No implementation found for void com.android.tools.aapt2.Aapt2.nativeCompile(java.util.List) #25

Open
rupeshkumar22 opened this issue Jul 23, 2021 · 2 comments

Comments

@rupeshkumar22
Copy link

rupeshkumar22 commented Jul 23, 2021

I faced no issue in loading the shared library in MainActivity.java
So I loaded the shared libraries from private storage as follows:

System.load("/data/data/com.myexample.runaapt2so/files/platform/x86/system/lib/libc++.so");
System.load("/data/data/com.myexample.runaapt2so/files/platform/x86/system/lib/libprotobuf-cpp-lite.so");
System.load("/data/data/com.myexample.runaapt2so/files/x86/lib/libaapt2.so");

I added two extra related x86 libraries before loading libaapt2.so to resolve some issues I found in the logs.
I used the java interface from here and created an instance of the Aapt2.java from MainActivity.java as follows:

Aapt2 aapt2Jni = new Aapt2();
List<String> list = new ArrayList<String>();
list.add("");
aapt2Jni.compile(list);

I face the following issue in the logs:

java.lang.UnsatisfiedLinkError: No implementation found for void com.android.tools.aapt2.Aapt2.nativeCompile(java.util.List) (tried Java_com_android_tools_aapt2_Aapt2_nativeCompile and Java_com_android_tools_aapt2_Aapt2_nativeCompile__Ljava_util_List_2)
        at com.android.tools.aapt2.Aapt2.nativeCompile(Native Method)
        at com.android.tools.aapt2.Aapt2.compile(Aapt2.java:15)
        at com.myexample.runaapt2so.MainActivity.onCreate(MainActivity.java:53)

Attaching the full project's google drive link

Tagging @JonForShort @timscriptov

@JonForShort
Copy link
Owner

Hi @rupesh-kumar-lpu , have you looked at using the binary instead of the shared library?

https://github.com/JonForShort/android-tools/tree/master/build/android-11.0.0_r33/aapt2/x86/bin

If you want to try to debug this issue, one suggestion is to dump the exported symbols using the command nm -gCD libaapt2.so and look through output to see if nativeCompile is in the list.

Hope this helps.

@rupeshkumar22
Copy link
Author

@JonForShort Binaries are helpful and works well, But now on a higher android API level I faced permission denied error while executing binaries with runtime.execute(). Will try to export symbols as you suggested. Thanks for the information.

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