Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to load Prebuilt Libraries ".so" files properly into android studio

Featured Replies

Posted

I'm using :

- windows 7 x64  

- Android studio 2.3.3 with offline gradle (gradle-4.2)

- Ndk is installed (android-ndk-r15c-windows-x86_64)

- CMake is installed (cmake-3.10.0-rc4)

- lldb for debuging is installed

Why the native method is always in red?

How to load  Prebuilt Libraries ".so" files properly into android studio?

If possible, i need a demo project for using prebuild libraries.

I attached a sample project for my work and a screen capture for android project.

Forgive me if i can't reply in time, i have a limited internet connection. 

--------------------------------
how to use Android.mk?
--------------------------------

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := foo-prebuilt
LOCAL_SRC_FILES := libfoo.so
include $(PREBUILT_SHARED_LIBRARY)


Thanks for help.

SoApp.rar

Capture.JPG

  • Author

Thanks CodeCracker for the reply, but the task is  not impossible.

It was described here hxxps://developer.android.com/ndk/guides/prebuilts.html

The problem is in my version of android studio or in the configuration of my project or something related.

Some persons have already done the task . Under MacOs for example  hxxps://www.youtube.com/watch?v=iVir4N55YQg

I need to do the job under windows. I already tried many tutorials but  always have  something wrong .

I can  load the  library but the native method cause an exception.

Did you add the necessary prefix to the native method (in the native library) as described in the documentation? What exception does the native method throw?

  • Author

Excuse me for being late.

What i'm doing is based to  samples from android ndk.

There is no prefix to add to the method according to officiel docs.

For the exception -------> " java.lang.UnsatisfiedLinkError: Native method not found"

 

That's because you changed the class name. In the official example (https://github.com/googlesamples/android-ndk/blob/master/hello-jni/app/src/main/java/com/example/hellojni/HelloJni.java) the class is named "HelloJni" and the native method is appropriately named  "Java_com_example_hellojni_HelloJni_stringFromJNI" (https://github.com/googlesamples/android-ndk/blob/master/hello-jni/app/src/main/cpp/hello-jni.c). If you change the name of the class, the prefix of the native method should change as well. This is defined in the JNI documentation (https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#jni_interface_functions_and_pointers, "Resolving Native Method Names") and perhaps more clearly, in the guide to the HelloJni sample (https://developer.android.com/ndk/samples/sample_hellojni.html, "C-side Implementation"). It should be something like "Java_com_ramzi_soapp_MainActivity_stringFromJNI".

  • Author

Thanks for the help, but something is not working for me. Take a look to the attached capture.

And if possible, do you have a working example.

Capture.JPG

The name of the native method looks better now. I also had trouble getting Android Studio to recognize the native method, but the apps I made still worked despite that. Unfortunately, I don't have them available anymore. Does your app still crash with the same exception when you run it on the phone now?

 

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.