I have a little app I am trying to run on my phone as I build it, to see if things are going properly. The trouble starts in
onCreate
in
MainActivity
, which looks like this:
public class MainActivity extends ListActivity {
public static final String TAG = "MAIN";
public static final String WEIGHTS_DIR = "/weights/input";
private String selectedFileName = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "Completed 'setContentView'.");
String topDir = Environment.getExternalStorageDirectory().getAbsolutePath() + WEIGHTS_DIR;
List<String> input_files = FileHelper.getInputFileNames(topDir);
Log.i(TAG, getString(input_files.size()) + " input files found.");
}
Before I add the
ListView
code, now commented out, the app starts up on my device, and debugging works nicely, stopping at breakpoints, examining variables, etc.
As soon as I add that code, I get the following messages:
Connected to the target VM, address: 'localhost:8610', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8610', transport: 'socket'
with "Disconnected" instantly after "Connected", where, when things were still nice, I would only get "Connected", and the main layout would display on the phone.
Then, on the phone, I clear the app's data and uninstall it, and comment out the
ListView
code, yet the debugging remains broken, with the instant "Disconnect" still there. I suspect some artefact in Android Studio's output is not being deleted when I rebuild, even after I do a clean. Once the debugging is broken like this, it also acts broken on an emulator for the phone, and a Nexus 9 emulator, so it really doesn't look device specific.
Worth noting is that if I do a Git reset on the branch I create before adding the
ListView
code, then debugging works again.
What I have tried:
I don't have much to try - I'm a complete Android Novice. If I copy all the code, minus the ListView stuff, into a new project, debugging works again. I have tried a breakpoint on the first line of the ListView stuff, so it doesn't execute until I want to, but the debugging still breaks as soon as I add that code. FileHelper is my own class, and getInputFileNames works fine and returns all files in the given directory.