AnchorFreePartner / hydrasdk-demo-android

Hydra VPN SDK demo app for Android
https://developer.anchorfree.com/
60 stars 31 forks source link

UnifiedSDK.update() NoSuchMethodError #116

Closed Nevaehy closed 3 years ago

Nevaehy commented 3 years ago

Got this error on some real devices (API 24, 28, 30) and some AVD (API 22, 19)

java.lang.NoSuchMethodError: No static method update(Lcom/anchorfree/sdk/NotificationConfig;)V in class Lcom/anchorfree/sdk/UnifiedSDK; or its super classes (declaration of 'com.anchorfree.sdk.UnifiedSDK' appears in /data/app/com.blazing.fast.vpn-1/base.apk)

Nevaehy commented 3 years ago

The code is:

private fun initHydraSdk() {
        val notificationConfig = NotificationConfig.newBuilder()
                .disabled()
                .build()
        UnifiedSDK.update(notificationConfig)                                        <-- Error occurs there

        val clientInfo = ClientInfo.newBuilder()
            .baseUrl(resources.getString(R.string.host_url_key))
            .carrierId(resources.getString(R.string.carrier_id_key))
            .build()
        val transportConfigList: MutableList<TransportConfig> = ArrayList()
        transportConfigList.add(HydraTransportConfig.create())
        transportConfigList.add(OpenVpnTransportConfig.tcp())
        transportConfigList.add(OpenVpnTransportConfig.udp())
        UnifiedSDK.update(transportConfigList, CompletableCallback.EMPTY)
        val config = UnifiedSDKConfig.newBuilder().idfaEnabled(false).build()
        UnifiedSDK.getInstance(clientInfo, config)
        UnifiedSDK.setLoggingLevel(Log.VERBOSE)
        UnifiedSDK.addVpnStateListener(this)
}

Any ideas what could be the source of the problem?

timoshenkoav commented 3 years ago

no idea, method is there. Maybe its due to kotlin issue to call static methods on java interfaces. Try to add kotlinOptions { jvmTarget = '1.8' }

Nevaehy commented 3 years ago

no idea, method is there. Maybe its due to kotlin issue to call static methods on java interfaces. Try to add kotlinOptions { jvmTarget = '1.8' }

This code is already present. On other devices and APIs everything works as intended.

timoshenkoav commented 3 years ago

we've checked the sdk on devices with api levels you've mentioned. no issue exits. Maybe you have some custom proguard settings?

Nevaehy commented 3 years ago

we've checked the sdk on devices with api levels you've mentioned. no issue exits. Maybe you have some custom proguard settings?

Proguard is empty. Also I tried settings that you specified in Readme. Had the same outcome.

timoshenkoav commented 3 years ago

from where do you have this stacktrace? just in logs? or in some crash logging system like firebase?

Nevaehy commented 3 years ago

Just in logs when I'm trying to launch app on AVD in Android Studio

timoshenkoav commented 3 years ago

ah, you can just skip it. it's just system logs, it still should work

Nevaehy commented 3 years ago

No, it doesn't. App crashes.

Nevaehy commented 3 years ago

123

Nevaehy commented 3 years ago

@timoshenkoav could you please reopen issue?

Nevaehy commented 3 years ago

At first, I've created an app that uses your SDK. Everything worked fine. Then, I've created a module (.aar) from this app and implemented it in absolutely clean, new project. And in this new project I've got this error on specified above devices.

timoshenkoav commented 3 years ago

just tried the app from this repo on AVD 22 - no crashes. Please check your app settings - dont think its sdk issue

timoshenkoav commented 3 years ago

if you made a lib check if you have runtime dependencies specified

Nevaehy commented 3 years ago

if you made a lib check if you have runtime dependencies specified

other APIs work fine, then all lib dependencies are fine too?

timoshenkoav commented 3 years ago

UnifiedSDK.update(notificationConfig) is the first api you call. what api do you call before?

timoshenkoav commented 3 years ago

try to build and run the app from this repo on the same device/avd

Nevaehy commented 3 years ago

UnifiedSDK.update(notificationConfig) is the first api you call. what api do you call before?

Nothing. I've tried .init() and others, but any api call results in crash and the same stacktrace error

timoshenkoav commented 3 years ago

so i suggest its dependency error. how do you specify the sdk dependency in aar library module? as 'implementation'? try the 'api'

Nevaehy commented 3 years ago

so i suggest its dependency error. how do you specify the sdk dependency in aar library module? as 'implementation'? try the 'api'

implementation 'com.github.AnchorFreePartner.hydra-sdk-android:sdk:3.3.3'
implementation 'com.github.AnchorFreePartner.hydra-sdk-android:openvpn:3.3.3'
timoshenkoav commented 3 years ago

try to change implementation to api

Nevaehy commented 3 years ago

try to change implementation to api

Just tried. Nothing has changed :(

timoshenkoav commented 3 years ago

hard to tell, try to build the app from this repo and run on the same avd/device - it should work

Nevaehy commented 3 years ago

Yep, I also tried it. It worked as a separate app, but not as an implemented module.

timoshenkoav commented 3 years ago

so you implemented it wrong

timoshenkoav commented 3 years ago

can you share your complete project sources that reproduce the issue?

Nevaehy commented 3 years ago

may I send link to repo via email?

timoshenkoav commented 3 years ago

sure - a.timoshenko@anchorfree.com

Nevaehy commented 3 years ago

sure - a.timoshenko@anchorfree.com

Great, thanks! Just sent you a message.

timoshenkoav commented 3 years ago

Do you have a requirement to make it as aar? Why not just do a library module in app module and add it as dependency

Nevaehy commented 3 years ago

yep, it's a requirement

timoshenkoav commented 3 years ago

ok, move vpn.aar to app/libs folder and add implementation fileTree(dir: 'libs', include: ['*.aar']) to app build.gradle image image

Nevaehy commented 3 years ago

Now I cannot go to VPNMainActivity because it's as unresolved reference now

timoshenkoav commented 3 years ago

you did something wrong image

timoshenkoav commented 3 years ago

i'm sending working project to you

Nevaehy commented 3 years ago

Should I keep this?

  1. include ':vpn' in settings.gradle
  2. vpn folder with .aar and .gradle file inside the project
timoshenkoav commented 3 years ago
  1. no, you can remove it 2.no, you can remove it
Nevaehy commented 3 years ago

I removed both and now it's unresolved reference for VPNMainActivity.. :)

timoshenkoav commented 3 years ago

check your email

Nevaehy commented 3 years ago

It works now, thank you!

But may I know the reason? Why didn't implementation project() work?

timoshenkoav commented 3 years ago

not sure, maybe its something with classloader

abkoradiya commented 2 years ago

@timoshenkoav I am getting this error when build aar file and use it. What is the solution?