3

I am trying to compile an app which still uses the, now deprecated, start/stopUsingNetworkFeature and requestRouteToHost.

To that end, I am following this answer.

However, I am still getting "Unresolved reference" errors for all three methods.

object NetworkFeatureWrapper {
    @Suppress("DEPRECATION")
    fun startUsingNetworkFeature(cm: ConnectivityManager, networkType: Int, feature: String) =
        cm.startUsingNetworkFeature(networkType, feature)
    …
}

I did also set the relevant SDK version in the build.gradle file

android {
    compileSdkVersion 25

    defaultConfig {
        minSdkVersion versions.minSdk // minSdk = 19
        targetSdkVersion 25
        versionCode versions.moduleVersionCode
        versionName versions.moduleVersionName

        compileOptions {
            sourceCompatibility versions.java
            targetCompatibility versions.java
        }
        testInstrumentationRunner libraries.androidJUnitRunner
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation libraries.kotlin
}

I tried downgrading the SDK even further, with no luck.

What am I doing wrong?

It as simple of a lib as possible, if you can even call it that.

Bruno
  • 3,872
  • 4
  • 20
  • 37
Iorpim
  • 167
  • 2
  • 9
  • It seems the build tools and/or lint have become more aggressive. I would expect the reflection method to still work, though. – Tenfour04 Mar 11 '21 at 14:47
  • @Tenfour04 shouldn't it still be fine from the build/lint perspective, since I am targeting the correct SDK? You should still be able to build an app for an older Android version – Iorpim Mar 11 '21 at 16:55
  • 1
    Yes it *should* be. They also shouldn't hide deprecated methods when the newer replacement isn't available in older versions of Android. Seems like an oversight. – Tenfour04 Mar 11 '21 at 17:08
  • @Tenfour04 feels like a fairly obvious oversight when there's still a significant number of users with older devices. Well, time to rewrite some code until someone decides to remove these methods entirely from the API… – Iorpim Mar 11 '21 at 18:03

0 Answers0