Changing Android SDK version causes crashes

Go To StackoverFlow.com

0

I have an Android application that connects and communicates with a server. Originally the app was built with minSdk version 8 (Android 2.2) and it worked perfectly. I have a device running 4.03, so I decided to create a minSdk 15 version. This caused my app to crash every time when trying to connect to the server.

I stripped the app down as much as possible to find the source of the problem. I narrowed the problem down to my function that initializes my Socket. Whenever this function tries to run the application crashes.

If I change the minSdk version to 8, it works perfectly. But it does not work on any other version that I have tried (10,14,15). I do not know what changed in the versions, but it seems odd that this would only work on misSdk 8. What could cause this or what could be changed?

Here is some of the code:

// Function that seems to cause problems
public void openConnection(){
    try{
        s = new Socket(InetAddress.getByName("192.168.1.84"),1500);
    }catch(IOException e){
e.printStackTrace();
    }
}
// Button handler
public void myClickHandler(View view){
    switch(view.getId()){
    case R.id.ConnectButton:
        this.openConnection();
    }
}
2012-04-03 22:03
by davemeyer
where is logcat stacktrace - Win Myo Htet 2012-04-03 22:16


1

I can't say for sure (post your logcat output!), but my best guess is that you are trying to make the connection on the UI thread and ICS is crashing your app (as it should, since attempting to connect to a web server on the UI thread is almost certainly a guarantee that your app will not function correctly). Ensure that you are making the connection using an AsyncTask or a Thread. I've seen a lot of developers with similar issues and usually related to this issue.

2012-04-03 23:07
by Alex Lockwood
That is exactly what I needed. I appreciate your quick and helpful response - davemeyer 2012-04-04 01:00
Ads