我正在尝试运行我的第一个 Android 应用程序,但在尝试运行它后它一直停止。谁能帮我解释为什么会发生这种情况?
我认为发生这种情况的一个原因是 GPRC 错误说:
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
值得庆幸的是,最近有一个问题询问此问题:Why do I get this GRPC Error "WARNING: EmulatorService.cpp:448: Cannot find certfile" when I start the emulator? ,但是那里的人向最初提问者提供的答案都不适合我。我尝试重新安装必要的 SDK 工具(模拟器、模拟器管理程序驱动程序、平台工具和模拟器加速器),但都没有成功。我还执行了“使缓存无效并重新启动”,检查了 XML 文件,卸载了应用程序,并完全重新启动了计算机,但无济于事。
所以我开始认为这里还有另一个问题,但我不知道是什么。
我的 MainActivity
是这样的,它只是将一些足球队分组:
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);
}
}
}
Tgroup
的代码如下:
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;
}
}
同时,Logcat 为空。预先感谢您!
(编辑:感谢您编辑标签!)
最佳答案
尝试将模拟器设置更改为硬件。 AVD 经理。使用铅笔按钮选择模拟设备设置。然后转到高级设置并将硬件设置从自动更改为硬件
关于java - 我的 Android 应用程序总是停止;是因为我因找不到证书文件而收到 GPRC 错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60472801/