Issue
In my test project, I use android "pay.cards" library (https://github.com/faceterteam/PayCards_Android) I include it as AAR and it works fine.
compile(name:'paycards-sdk-release', ext:'aar')
Then I add in project native method call.
public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("native-lib");
}
private native String getFirstName();
private native String getLastName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((TextView)findViewById(R.id.tv1)).setText(getFirstName());
((TextView)findViewById(R.id.tv2)).setText(getLastName());
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
...
After that, pay.scan library cannot load libraries:
static {
System.loadLibrary("opencv_java3");
System.loadLibrary("cardrecognizer");
}
In this case java.lang.UnsatisfiedLinkError in thrown.
dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/-2/base.apk"],nativeLibraryDirectories=[/lib/arm64, /system/fake-libs64, /data/app/-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libopencv_java3.so"
But, when I disable my own native methods (just removing externalNativeBuild section from build.gradle), everything works as expected again.
Could anyone advise something in this situation?
I'm new in NDK dev, so any ideas would be helpful for me.
Solution
As you see, the cardrecognizer library is built for 32-bit ARM (armeabi-v7a). In the short run, you can build you native library for the same ABI. This is usually controlled by abiFilters in the build.gradle script.
But if you intend to distribute your app on Play Store, you should learn to build the third-party library for arm64, too. Google announced this requirement for August 2019.
Answered By - Alex Cohn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.