I am trying to run my very first Android app, but it keeps stopping after trying to run it. Can anyone help me as to why this happens?
One reason I think this happens is because of an GPRC error saying:
Emulator: emulator: WARNING: EmulatorService.cpp:448: Cannot find certfile: C:\Users\HOME.android\emulator-grpc.cer security will be disabled.
Emulator: Started GRPC server at 127.0.0.1:8554
Thankfully, there was a recent question asking about this problem at: Why do I get this GRPC Error "WARNING: EmulatorService.cpp:448: Cannot find certfile" when I start the emulator? , but none of the answers the people there provided to the original asker worked out for me. I've tried reinstalling the necessary SDK Tools (the emulator, the emulator hypervisor driver, the platform tools, and the emulator accelerator) but none of them worked out. I've also done "Invaliidate caches and restart", checked the XML files, uninstalling the app, and restarted the computer altogether, to no avail.
So I'm starting to think there's another problem here, but I don't know what.
My MainActivity
goes like this, it's just sorting some soccer teams into groups:
package com.example.basicsorting;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Tgroup> groups = new ArrayList<>();
groups.add(new Tgroup('1', "A"));
groups.add(new Tgroup('2', "B"));
groups.add(new Tgroup('3', "C"));
groups.add(new Tgroup('4', "D"));
List<String> ht = Arrays.asList("A", "B", "C", "D");
List<String> ttd = Arrays.asList("E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P");
Map<String, Tgroup> drawResult = new HashMap<>();
Random random = new Random();
for (int i = 0; i < ht.size(); i++){
drawResult.put(ht.get(i), groups.get(i));
}
for (String team : ttd){
int index = random.nextInt(ttd.size());
drawResult.put(team, groups.get(index));
}
for(Map.Entry<String, Tgroup> e : drawResult.entrySet()){
Log.d("Cup", e.getKey() + "got drawn to Group" + e.getValue().name +
"so they will have to book a place at " + e.getValue().hostcity);
}
}
}
And the code for Tgroup
goes like this:
package com.example.basicsorting;
public class Tgroup {
public char name;
public String hostcity;
Tgroup(char name, String hostcity) {
this.name = name; // value is equal to whatever the user passed in
this.hostcity = hostcity;
}
}
Meanwhile, Logcat was empty. Thank you in advance!
(Edit: thanks for editing the tags!)