Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find method 'requestRouteToHost(int,int)' in class android.net.ConnectivityManager targeting SDK version 26 #633

Closed
paolorotolo opened this issue Jul 18, 2017 · 6 comments
Milestone

Comments

@paolorotolo
Copy link

I'm unable to build an APK with ProGuard enabled targeting Android O SDK version (targetSdkVersion 26).

Log:

Information: Gradle tasks [:app:assembleRelease]
Warning: org.osmdroid.tileprovider.modules.NetworkAvailabliltyCheck: can't find referenced method 'boolean requestRouteToHost(int,int)' in library class android.net.ConnectivityManager
Warning:there were 1 unresolved references to library class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
@paolorotolo
Copy link
Author

paolorotolo commented Jul 18, 2017

Anyway, you can suppress the warning adding this in ProGuard rules:

-dontwarn org.osmdroid.tileprovider.modules.NetworkAvailabliltyCheck

@paolorotolo
Copy link
Author

You may also need mybuild.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.github.paolorotolo.osmtest"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {

            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    compile 'org.osmdroid:osmdroid-android:5.6.5'

@spyhunter99
Copy link
Collaborator

thanks for the tip. i'll add it to our sample pro guard file

@spyhunter99 spyhunter99 modified the milestone: v5.6.6 Jul 29, 2017
daniele-athome added a commit to kontalk/androidclient that referenced this issue Aug 24, 2017
Apparently, ConnectivityManager.requestRouteToHost was *removed* from
the source code in API level 26. This might cause problems on Android O,
and adding a dontwarn to ProGuard isn't really the ideal solution.

Signed-off-by: Daniele Ricci <daniele.athome@gmail.com>
@secaw
Copy link
Contributor

secaw commented Feb 3, 2018

Well, the -dontwarn really is a dirty work around. requestRouteToHost(int,int) has been removed in API 26. It's being called in NetworkAvailabliltyCheck.getRouteToPathExists(final int hostAddress), which doesn't seem to be used anywhere. So either we should come up with a replacement for requestRouteToHost(int,int) there or just remove method getRouteToPathExists from NetworkAvailabliltyCheck and INetworkAvailablityCheck.

@spyhunter99 spyhunter99 reopened this Feb 3, 2018
@spyhunter99 spyhunter99 added this to the v6.0.0 milestone Feb 3, 2018
spyhunter99 added a commit that referenced this issue Feb 3, 2018
… android.net.ConnectivityManager targeting SDK version 26
@spyhunter99
Copy link
Collaborator

just committed the change and updated the snapshots

@secaw
Copy link
Contributor

secaw commented Feb 3, 2018

Great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants