跳过172帧!应用程序可能在其主线程上做了太多的工作

w8f9ii69  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(299)

在我的java项目中,只有用户登录和注册,其中只有按钮的活动。当我第二次运行模拟器时,我得到这样一个警告。当我想进入注册页面时,它会发送到带有按钮的页面。或者用户登录页在第一次打开时没有打开。警报如下所示:跳过172帧!应用程序可能在其主线程上做了太多的工作。我是新来的安卓编程,如果你能帮忙我会很感激的。
androidmanifest.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.example.geziproject">
  4. <uses-permission android:name="android.permission.INTERNET"/>
  5. <application
  6. android:allowBackup="true"
  7. android:icon="@mipmap/ic_launcher"
  8. android:label="@string/app_name"
  9. android:roundIcon="@mipmap/ic_launcher_round"
  10. android:supportsRtl="true"
  11. android:theme="@style/Theme.Geziproject">
  12. <activity android:name=".bos"/>
  13. <activity android:name=".kayitol" />
  14. <activity android:name=".kullanicigiris">
  15. <intent-filter>
  16. <action android:name="android.intent.action.MAIN" />
  17. <category android:name="android.intent.category.LAUNCHER" />
  18. </intent-filter>
  19. </activity>
  20. </application>
  21. </manifest>

kayitol.java文件

  1. public class kayitol extends AppCompatActivity {
  2. private EditText txtAd, txtEmail, txtŞifre;
  3. private Button btnkayit;
  4. FirebaseAuth mFirebaseAuth;
  5. //DatabaseReference yol;
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_kayitol);
  10. mFirebaseAuth = FirebaseAuth.getInstance();
  11. txtAd = findViewById(R.id.txtad);
  12. txtEmail = findViewById(R.id.txtEmail);
  13. txtŞifre = findViewById(R.id.txtŞifre);
  14. btnkayit = findViewById(R.id.kayit);
  15. btnkayit.setOnClickListener(v -> {
  16. String email = txtEmail.getText().toString();
  17. String pwd = txtŞifre.getText().toString();
  18. if (email.isEmpty()) {
  19. txtEmail.setError("Lütfen email giriniz");
  20. txtEmail.requestFocus();
  21. } else if (pwd.isEmpty()) {
  22. txtŞifre.setError("Lütfen şifre giriniz");
  23. txtŞifre.requestFocus();
  24. } else if (email.isEmpty() && pwd.isEmpty()) {
  25. Toast.makeText(kayitol.this, "Bu alanlar boş bırakılamaz", Toast.LENGTH_LONG).show();
  26. } else if (!(email.isEmpty() && pwd.isEmpty())) {
  27. mFirebaseAuth.createUserWithEmailAndPassword(email, pwd).addOnCompleteListener(kayitol.this, task -> {
  28. if (!task.isSuccessful()) {
  29. Toast.makeText(kayitol.this, "Kayıt başarısız,tekrar deneyiniz", Toast.LENGTH_LONG).show();
  30. } else {
  31. Intent intent = new Intent(kayitol.this, bos.class);
  32. startActivity(intent);
  33. }
  34. });
  35. } else {
  36. Toast.makeText(kayitol.this, "Hata oluştu", Toast.LENGTH_LONG).show();
  37. }
  38. });
  39. }
  40. }

kullanicigiris.java文件

  1. public class kullanicigiris extends AppCompatActivity {
  2. Button btngiris;
  3. Button btnkayit;
  4. FirebaseAuth mFirebaseAuth;
  5. private EditText txtad;
  6. private EditText txtemail;
  7. private EditText txtsifre;
  8. private FirebaseAuth.AuthStateListener mAuthListener;
  9. @Override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.activity_kullanicigiris);
  13. mFirebaseAuth = FirebaseAuth.getInstance();
  14. Button btngiris = findViewById(R.id.giris);
  15. Button btnkayit = findViewById(R.id.kayit);
  16. txtad = findViewById(R.id.txtad);
  17. txtemail = findViewById(R.id.txtemaili);
  18. txtsifre = findViewById(R.id.txtŞifre);
  19. mAuthListener = firebaseAuth -> {
  20. FirebaseUser mFirebaseUser = mFirebaseAuth.getCurrentUser();
  21. if (mFirebaseUser != null) {
  22. Toast.makeText(kullanicigiris.this, "giriş yaptın", Toast.LENGTH_LONG).show();
  23. Intent i = new Intent(kullanicigiris.this, bos.class);
  24. startActivity(i);
  25. } else {
  26. Toast.makeText(kullanicigiris.this, "lütfen giriş yapın", Toast.LENGTH_LONG).show();
  27. }
  28. };
  29. btngiris.setOnClickListener(v -> {
  30. String email = txtemail.getText().toString();
  31. String pwd = txtsifre.getText().toString();
  32. if (email.isEmpty()) {
  33. txtemail.setError("Lütfen email giriniz");
  34. txtemail.requestFocus();
  35. } else if (pwd.isEmpty()) {
  36. txtsifre.setError("Lütfen şifre giriniz");
  37. txtsifre.requestFocus();
  38. } else if (email.isEmpty() && pwd.isEmpty()) {
  39. Toast.makeText(kullanicigiris.this, "Bu alanlar boş bırakılamaz", Toast.LENGTH_LONG).show();
  40. } else if (!(email.isEmpty() && pwd.isEmpty())) {
  41. mFirebaseAuth.signInWithEmailAndPassword(email, pwd).addOnCompleteListener(kullanicigiris.this, task -> {
  42. if (!task.isSuccessful()) {
  43. Toast.makeText(kullanicigiris.this, "Giriş başarısız ,tekrar deneyiniz", Toast.LENGTH_LONG).show();
  44. } else {
  45. txtad.setText("");
  46. txtemail.setText("");
  47. txtsifre.setText("");
  48. startActivity(new Intent(kullanicigiris.this, bos.class));
  49. }
  50. });
  51. } else {
  52. Toast.makeText(kullanicigiris.this, "Hata oluştu", Toast.LENGTH_LONG).show();
  53. }
  54. });
  55. btnkayit.setOnClickListener(v -> {
  56. Intent i = new Intent(kullanicigiris.this, kayitol.class);
  57. startActivity(i);
  58. });
  59. }
  60. @Override
  61. protected void onStart() {
  62. super.onStart();
  63. mFirebaseAuth.addAuthStateListener(mAuthListener);
  64. }
  65. }

bos.java文件

  1. public class bos extends AppCompatActivity {
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. setContentView(R.layout.activity_bos);
  6. }
  7. }

跑步:

  1. 12/07 16:40:12: Launching 'app' on Pixel.
  2. Install successfully finished in 2 s 552 ms.
  3. $ adb shell am start -n "com.example.geziproject/com.example.geziproject.kullanicigiris" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
  4. Connected to process 7342 on device 'emulator-5554'.
  5. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
  6. I/ple.geziprojec: Not late-enabling -Xcheck:jni (already on)
  7. I/ple.geziprojec: Unquickening 12 vdex files!
  8. W/ple.geziprojec: Unexpected CPU variant for X86 using defaults: x86
  9. D/NetworkSecurityConfig: No Network Security Config specified, using platform default
  10. D/NetworkSecurityConfig: No Network Security Config specified, using platform default
  11. I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
  12. W/ple.geziprojec: Verification of boolean com.google.android.gms.common.GoogleApiAvailabilityLight.isPlayServicesPossiblyUpdating(android.content.Context, int) took 251.962ms (19.84 bytecodes/s) (776B approximate peak alloc)
  13. W/ple.geziprojec: Verification of com.google.android.gms.tasks.Task com.google.android.gms.common.GoogleApiAvailability.makeGooglePlayServicesAvailable(android.app.Activity) took 120.192ms (316.16 bytecodes/s) (1400B approximate peak alloc)
  14. I/FirebaseInitProvider: FirebaseApp initialization successful
  15. D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
  16. D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
  17. D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
  18. W/ple.geziprojec: Verification of void com.google.android.gms.common.api.internal.GoogleApiManager$zaa.<init>(com.google.android.gms.common.api.internal.GoogleApiManager, com.google.android.gms.common.api.GoogleApi) took 115.333ms (945.09 bytecodes/s) (3688B approximate peak alloc)
  19. W/ple.geziprojec: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
  20. W/ple.geziprojec: Verification of void com.google.android.gms.common.api.internal.GoogleApiManager$zaa.onConnected(android.os.Bundle) took 141.826ms (246.78 bytecodes/s) (1264B approximate peak alloc)
  21. W/ple.geziprojec: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
  22. D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10153; state: ENABLED
  23. D/HostConnection: HostConnection::get() New Host Connection established 0xeaedfd50, tid 7393
  24. D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
  25. W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
  26. D/EGL_emulation: eglCreateContext: 0xeaeded90: maj 2 min 0 rcv 2
  27. D/EGL_emulation: eglMakeCurrent: 0xeaeded90: ver 2 0 (tinfo 0xeb222df0) (first time)
  28. I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to fallback implementation
  29. I/Gralloc4: mapper 4.x is not supported
  30. D/HostConnection: createUnique: call
  31. D/HostConnection: HostConnection::get() New Host Connection established 0xeaedfb20, tid 7393
  32. D/goldfish-address-space: allocate: Ask for block of size 0x100
  33. allocate: ioctl allocate returned offset 0x3fcf6d000 size 0x2000
  34. D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
  35. I/OpenGLRenderer: Davey! duration=976ms; Flags=1, IntendedVsync=1293927629619, Vsync=1293977629617, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1293986896900, AnimationStart=1293986963100, PerformTraversalsStart=1293987049900, DrawStart=1294410491800, SyncQueued=1294418169100, SyncStart=1294436241500, IssueDrawCommandsStart=1294436512100, SwapBuffers=1294778679200, FrameCompleted=1294922281100, DequeueBufferDuration=187900, QueueBufferDuration=733800, GpuCompleted=0,
  36. I/Choreographer: Skipped 61 frames! The application may be doing too much work on its main thread.
nszi6y05

nszi6y051#

一般来说,在模拟器上跳过200帧左右的帧往往只是延迟。这是意料之中的;模拟器相当慢。在您目前的状态下,这可能是一个您可以放心忽略的问题。
你可以关闭电脑上其他不必要的程序,看看情况是否好转。你可能会跳过几帧不管怎样,但它通常是好的。
如果跳过的帧数足够大,严重影响实际硬件上的用户体验,那么这个问题才是一个严重的问题。在300多帧的范围内
有关详细信息,请参阅android ui:fixing skipped frames

相关问题