hoerresb / WifiWizard

A Cordova plugin for managing Wifi networks
Apache License 2.0
205 stars 178 forks source link

Build Failed: package NetworkInfo does not exist #106

Closed vicatcu closed 7 years ago

vicatcu commented 7 years ago

Using this AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.ionicwifiscan2750985" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="24" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

I am getting this error when I run ionic build android.

/home/vic/git/ionicwifiscan2/platforms/android/src/com/pylonproducts/wifiwizard/WifiWizard.java:275: error: package NetworkInfo does not exist
              NetworkInfo.DetailedState connectionState = info.getDetailedStateOf(info.getSupplicantState());
                         ^

/home/vic/git/ionicwifiscan2/platforms/android/src/com/pylonproducts/wifiwizard/WifiWizard.java:281: error: package NetworkInfo does not exist
                              connectionState == NetworkInfo.DetailedState.CONNECTED ||
                                                            ^
/home/vic/git/ionicwifiscan2/platforms/android/src/com/pylonproducts/wifiwizard/WifiWizard.java:283: error: package NetworkInfo does not exist
                              (connectionState == NetworkInfo.DetailedState.OBTAINING_IPADDR && info.getIpAddress() != 0)
                                                             ^

Note: /home/vic/git/ionicwifiscan2/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

3 errors

fwiw java -version on my machine:

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Please can someone tell me what I might be doing wrong / what i should be doing differently?

vicatcu commented 7 years ago

Update... similar to issue #51, I edited /home/vic/git/ionicwifiscan2/platforms/android/src/com/pylonproducts/wifiwizard/WifiWizard.java to add to the list of imports:

import android.net.NetworkInfo;

and build succeeded... seems to me like I shouldn't need to do this... what gives?

vicatcu commented 7 years ago

OK... so 0.2.11 has this build problem fixed

vicatcu commented 7 years ago

OK, what gives... I have to have GPS enabled to get wifi scan results!?