Error undefined symbol uplink request access with passphrase setting up access to storj project

Hello,
I am new at Storj, I am testing it a little bit in a simple android app before developing the complex one.
I have problems in the very first steps. Following the readme, I have added the dependency in the build.gradle and the app builds correctly but I have runtime error when I execute the following code:

this.uplink = new Uplink();
try {
this.access = uplink.requestAccessWithPassphrase(satelliteAddress,serializedApiKey,passphrase);
}catch (StorjException e){
Log.e(“STORJ”, e.toString());
}

The error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.teststorj, PID: 10041
java.lang.UnsatisfiedLinkError: Error looking up function ‘uplink_request_access_with_passphrase’: undefined symbol: uplink_request_access_with_passphrase
at com.sun.jna.Function.(Function.java:252)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:600)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:576)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:562)
at com.sun.jna.Library$Handler.invoke(Library.java:243)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at io.storj.$Proxy5.uplink_request_access_with_passphrase(Unknown Source)
at io.storj.Uplink.requestAccessWithPassphrase(Uplink.java:65)
at com.example.teststorj.MainActivity.initializeStorj(MainActivity.java:60)

It seems like it is not seeing correctly the library code but I don’t know what to do because I have just added the dependency and tried this in my main activity and the app compiles correctly.
The three parameters have the correct value, and the error message doesn’t seem caused from a possible wrong key.

What can be the cause?

Hope everything is clear

I guess, you are trying the binding for Java from there: GitHub - storj/uplink-java: Storj network Java library
Did you build the uplink-c binary as required?

You need the uplink-c binary, which can be built with ./scripts/build-uplink.sh .

Have you tried to build an example app from there?

@lucaferro It’s hard to say why this error happens without knowing more about your app setup.

Here is what I have done to test the Storj Android library quickly:

  1. Downloaded and installed the latest Android Studio.
  2. Created a new virtual device.
  3. Created a new project with Basic Activity and all defaults.
  4. Added the implementation 'io.storj:uplink-android:1.0.0-rc.1' dependency to app/build.gradle.
  5. Added android.enableJetifier=true to gradle.properties. Otherwise, the build complains that the Storj library is a legacy one.
  6. Added <uses-permission android:name="android.permission.INTERNET"/> to app/src/main/AndroidManifest.xml.
  7. Modified the code of the OnClickListener of the onCreate method in app/src/main/java/com/example/myapplication/MainActivity.kt to look like this:
binding.fab.setOnClickListener { view ->
    val satelliteAddress = "12EayRS2V1kEsWESU9QMRseFhdxYxKicsiFmxrsLZHeLUtdps3S@us1.storj.io:7777"
    val serializedApiKey = "redacted"
    val passphrase = "super secret passphrase"
    val uplink = Uplink()
    val access = uplink.requestAccessWithPassphrase(satelliteAddress, serializedApiKey, passphrase)
    Snackbar.make(view, access.serialize(), Snackbar.LENGTH_LONG)
            .setAction("Action", null).show()
}

Now, when you run the app and tap on the action button in the bottom right corner, it will execute the above the code and will display the result access grant.

I hope this helps.

3 Likes

Sorry that wasn’t clear, right now I am using GitHub - storj/uplink-android: Storj network Android library.
Following its readme the gradle dependency should be all I need but it seems like something isn’t building the right way and I don’t find any build-uplink file in my project

I see. This documentation seems outdated and doesn’t contain everything needed to get libraries.
Have you tried the suggestion above?

Thank you for the answer. These are the same steps I did when I added storj code into a small other project I had where I made users take a picture to upload. For some reasons it didn’t work there but, as suggested in your answer, retrying in a new project with some fixes seems to work.
I am not sure if it was a strange combination of plugins which conflicted ore some changes in the manifest (for example I did not know that for api>30 was needed package name declaration.

After these changes I managed to integrate the storj in the old project’s functionality.
I am very grateful to both of you

2 Likes

A post was split to a new topic: Is there a way to get the share link of an uploaded file through an api call?