Android studio在第35行给出了一个错误,并没有确切地显示logcat只是指向第35行的错误

798qvoo8  于 2023-06-27  发布在  Android
关注(0)|答案(1)|浏览(145)
  1. package com.example.secondar;
  2. import androidx.appcompat.app.AppCompatActivity;
  3. import androidx.recyclerview.widget.LinearLayoutManager;
  4. import androidx.recyclerview.widget.RecyclerView;
  5. import android.net.Uri;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import com.google.ar.core.Anchor;
  10. import com.google.ar.sceneform.AnchorNode;
  11. import com.google.ar.sceneform.rendering.ModelRenderable;
  12. import com.google.ar.sceneform.ux.ArFragment;
  13. import com.google.ar.sceneform.ux.TransformableNode;
  14. import java.util.ArrayList;
  15. public class MainActivity extends AppCompatActivity {
  16. private ArFragment arFragment;
  17. private ArrayList<Integer> imagesPath = new ArrayList<Integer>();
  18. private ArrayList<String> namesPath = new ArrayList<>();
  19. private ArrayList<String> modelNames = new ArrayList<>();
  20. AnchorNode anchorNode;
  21. private Button btnRemove;
  22. @Override
  23. protected void onCreate(Bundle savedInstanceState) {
  24. super.onCreate(savedInstanceState);
  25. setContentView(R.layout.activity_main);
  26. arFragment = (ArFragment)getSupportFragmentManager().findFragmentById(R.id.fragment);
  27. btnRemove = (Button)findViewById(R.id.remove);
  28. getImages();
  29. arFragment.setOnTapArPlaneListener((hitResult, plane, motionEvent) -> {
  30. Anchor anchor = hitResult.createAnchor();
  31. ModelRenderable.builder()
  32. .setSource(this,Uri.parse(Common.model))
  33. .build()
  34. .thenAccept(modelRenderable -> addModelToScene(anchor,modelRenderable));
  35. });

i tried every possible video on youtube aint working它不工作的应用程序不断崩溃每次我尝试运行它它不打开在所有它的行setContentView这是行logcat是引导我当我点击蓝色链接在logcat我已经尝试清理和building它再次也该高速缓存但似乎没有工作

44u64gxh

44u64gxh1#

请确保您必须更新您的工作室在最新版本。但你可以从下面的几点进行检查。

1.检查日志级别和过滤:确保Logcat工具栏中的日志级别设置为“Error”或“Verbose”,以捕获所有日志消息,包括错误和崩溃。此外,请确保没有应用可能会排除崩溃日志的特定包名称或日志消息筛选器。
1.增加日志缓冲区大小:如果日志缓冲区大小不足,则崩溃日志可能会被截断。单击Logcat工具栏中的齿轮图标,并将“Maximum number of logcat messages to buffer”设置增加到更高的值。这允许保留和显示更多日志消息,包括崩溃日志。
1.开启严格模式:在应用的开发配置中启用严格模式。严格模式有助于检测和报告代码中可能导致崩溃的潜在问题和违规行为。它可以提供常规logcat中可能无法捕获的有关潜在问题的附加日志记录和信息。
1.检查异常处理:确保在代码中有正确的异常处理。未处理的异常可能会导致应用崩溃,而不会生成显式的logcat消息。实现try-catch块或全局异常处理程序来捕获和记录任何未处理的异常。
1.检查ProGuard设置:如果您使用ProGuard进行代码混淆和缩小,请确保正确配置了ProGuard规则。ProGuard可能会混淆与崩溃报告相关的类或方法名称,导致日志信息量较少或缺少重要细节。查看ProGuard规则以保留必要的崩溃报告类或禁用它们的模糊处理。
1.物理设备测试:有时,在模拟器上测试时,与崩溃相关的日志消息可能不会显示在Logcat中。尝试在物理设备上测试您的应用,查看是否正确捕获了崩溃日志。
1.更新Android Studio和SDK工具:确保您使用的是最新版本的Android Studio和SDK工具。过时的版本可能有影响logcat功能的bug或限制。更新到最新的稳定版本,以从错误修复和改进中受益。

也尝试调试一步一步,检查你的崩溃。

相关问题