0

I am making Android project on IntelliJ. Now what I'm trying to do is connecting servlet.java which is within the same package of the Android project from MainActivity.java which is Android.java. The code of Android side is below.

 URL url = new URL("http://localhost:8080/AndroidProject/Servlet/");
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept","text/plain");
            status = connection.getResponseCode();

But when I ran the program, After "status = connection.getResponseCode();", "Source code does not match the bytecode" came up at Looper.java. Meanwhile, when I did the same thing at client-servlet java without Android, it worked normally. So what do I need to do? what is the difference between the Android connection and client-server connection?

I checked the following info.
'Source code does not match the bytecode' when debugging on a device

I checked build.gradle. The API information is

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.example.androidapp"
        minSdkVersion 29
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

So based on the information, I added the following at AndroidManifest.xml. But still, the same error happens.

<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
mufugu
  • 13
  • 4

0 Answers0