使用辅助功能服务在 Android 手机上截取屏幕截图总是失败并出现内部错误

问题描述 投票:0回答:1

我正在尝试创建一个应用程序,该应用程序允许我在按下按钮后截取另一个应用程序当前显示的屏幕的屏幕截图。每次我按下按钮并启动截图服务时,它都会失败并返回错误代码1。谁能解释为什么它总是返回错误代码1并告诉我使用Android AccessibilityService截图的正确方法。

public class AutoService extends AccessibilityService {
    private Handler mHandler;
    public static Bitmap sudokuMap = null;
    public static boolean result;

    @Override
    public void onCreate() {
        super.onCreate();
        HandlerThread handlerThread = new HandlerThread("auto-handler");
        handlerThread.start();
        mHandler = new Handler(handlerThread.getLooper());
    }

    @Override
    protected void onServiceConnected() {
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d("Service","SERVICE STARTED");
        if (intent != null) {
            String action = intent.getStringExtra("action");
            if (action.equals("capture")) {
                if (mRunnable == null) {
                    mRunnable = new IntervalRunnable();
                }
                mHandler.post(mRunnable);

                Toast.makeText(getBaseContext(), "Started", Toast.LENGTH_SHORT).show();
            }
            else if (action.equals("stop")) {
                mHandler.removeCallbacksAndMessages(null);
            }
        }

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void takeScreenshot(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback) {
        super.takeScreenshot(displayId, executor, callback);
    }

    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
    }

    @Override
    public void onInterrupt() {
    }

    public void screenshot() {
        Log.d("SCREENSHOT", "trying to capture");
        takeScreenshot(Display.DEFAULT_DISPLAY, getApplicationContext().getMainExecutor(), new TakeScreenshotCallback() {
            @Override
            public void onSuccess(@NonNull ScreenshotResult screenshotResult) {
                Log.d("SCREENSHOT", "Success");
                sudokuMap = Bitmap.wrapHardwareBuffer(screenshotResult.getHardwareBuffer(), screenshotResult.getColorSpace());
                sudokuMap = Bitmap.createBitmap(sudokuMap, 39,498,1002,1002);
                result = true;
                Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_LONG).show();
                saveImage(sudokuMap);
            }

            @Override
            public void onFailure(int i) {
                Log.d("SCREENSHOT", "Failed " + i);
                sudokuMap = Bitmap.createBitmap(1,1, Bitmap.Config.ARGB_8888);
                result = false;
                Toast.makeText(getBaseContext(), "Failed " + i, Toast.LENGTH_LONG).show();
            }
        });
    }

    private void saveImage(Bitmap image) {
        File root = Environment.getExternalStorageDirectory();
        File file = new File(root.getAbsolutePath()+"/DCIM/test/test.png");
        File dir = new File(root.getAbsolutePath()+"/DCIM/test");
        if (!dir.exists())
            dir.mkdir();
        try {
            file.createNewFile();
            OutputStream outputStream = new FileOutputStream(file);
            image.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
            outputStream.close();
            Toast.makeText(getBaseContext(), "Image saved", Toast.LENGTH_SHORT).show();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private IntervalRunnable mRunnable;

    private class IntervalRunnable implements Runnable {
        @Override
        public void run() {
            Log.d("SCREENSHOT","Started");
            screenshot();
        }
    }
}

进入服务后,程序会通过run()方法开始截图。

日志详细信息如下

2023-08-12 15:37:31.838 31840-31840 ActivityThread          com.example.sudokusolver             W  Application com.example.sudokusolver can be debugged on port 8100...
2023-08-12 15:37:31.850 31840-31840 le.sudokusolve          com.example.sudokusolver             W  ClassLoaderContext classpath size mismatch. expected=0, found=1 (PCL[] | PCL[/data/data/com.example.sudokusolver/code_cache/.overlay/base.apk/classes4.dex*4114240452])
2023-08-12 15:37:31.850 31840-31840 le.sudokusolve          com.example.sudokusolver             W  Found duplicate classes, falling back to extracting from APK : /data/app/~~SulUYZxd5YnqTvrkNbJQdw==/com.example.sudokusolver-W8DCKxBEqhN-8T7rr30ACQ==/base.apk
2023-08-12 15:37:31.851 31840-31840 le.sudokusolve          com.example.sudokusolver             W  NOTE: This wastes RAM and hurts startup performance.
2023-08-12 15:37:31.851 31840-31840 le.sudokusolve          com.example.sudokusolver             W  Found duplicated class when checking oat files: 'Lcom/example/sudokusolver/AutoService$1;' in /data/data/com.example.sudokusolver/code_cache/.overlay/base.apk/classes4.dex and /data/app/~~SulUYZxd5YnqTvrkNbJQdw==/com.example.sudokusolver-W8DCKxBEqhN-8T7rr30ACQ==/base.apk!classes4.dex
2023-08-12 15:37:32.070 31840-31840 NetworkSecurityConfig   com.example.sudokusolver             D  No Network Security Config specified, using platform default
2023-08-12 15:37:32.070 31840-31840 NetworkSecurityConfig   com.example.sudokusolver             D  No Network Security Config specified, using platform default
2023-08-12 15:37:32.075 31840-31840 libc                    com.example.sudokusolver             E  Access denied finding property "ro.vendor.pref_scale_resolution"
2023-08-12 15:37:32.104 31840-31887 libMEOW                 com.example.sudokusolver             D  meow reload base cfg path: na
2023-08-12 15:37:32.104 31840-31887 libMEOW                 com.example.sudokusolver             D  meow reload overlay cfg path: na
2023-08-12 15:37:32.105 31840-31887 libMEOW                 com.example.sudokusolver             D  applied 1 plugins for [com.example.sudokusolver]:
2023-08-12 15:37:32.105 31840-31887 libMEOW                 com.example.sudokusolver             D    plugin 1: [libMEOW_gift.so]:
2023-08-12 15:37:32.148 31840-31840 AppCompatDelegate       com.example.sudokusolver             D  Checking for metadata for AppLocalesMetadataHolderService : Service not found
2023-08-12 15:37:32.177 31840-31840 View                    com.example.sudokusolver             D  com.example.sudokusolver initForcedUseForceDark: 1
2023-08-12 15:37:32.184 31840-31840 DecorView[]             com.example.sudokusolver             D  getWindowModeFromSystem  windowmode is 1
2023-08-12 15:37:32.185 31840-31840 DecorView               com.example.sudokusolver             D  createDecorCaptionView windowingMode:1 mWindowMode 1 isFullscreen: true
2023-08-12 15:37:32.244 31840-31840 le.sudokusolve          com.example.sudokusolver             W  Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2023-08-12 15:37:32.245 31840-31840 le.sudokusolve          com.example.sudokusolver             W  Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2023-08-12 15:37:32.352 31840-31840 SurfaceFactory          com.example.sudokusolver             I  [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@6e07aeb
2023-08-12 15:37:32.358 31840-31840 ViewRootIm...nActivity] com.example.sudokusolver             D  hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
2023-08-12 15:37:32.363 31840-31840 libMEOW                 com.example.sudokusolver             D  applied 1 plugins for [com.example.sudokusolver]:
2023-08-12 15:37:32.363 31840-31840 libMEOW                 com.example.sudokusolver             D    plugin 1: [libMEOW_gift.so]:
2023-08-12 15:37:32.363 31840-31840 InputTransport          com.example.sudokusolver             I  Create ARC handle: 0xb400007c589ddb20
2023-08-12 15:37:32.366 31840-31840 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:37:32.367 31840-31840 Looper                  com.example.sudokusolver             W  PerfMonitor looperActivity : package=com.example.sudokusolver/.MainActivity time=275ms latency=326ms running=251ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.LaunchActivityItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem } historyMsgCount=3 (msgIndex=1 wall=65ms seq=1 running=62ms runnable=1ms late=4ms h=android.app.ActivityThread$H w=162) (msgIndex=3 wall=263ms seq=3 running=247ms late=64ms h=android.app.ActivityThread$H w=110)
2023-08-12 15:37:32.368 31840-31840 Looper                  com.example.sudokusolver             W  PerfMonitor looperActivity : package=com.example.sudokusolver/.MainActivity time=0ms latency=601ms running=0ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] } historyMsgCount=4 (msgIndex=1 wall=65ms seq=1 running=62ms runnable=1ms late=4ms h=android.app.ActivityThread$H w=162) (msgIndex=3 wall=263ms seq=3 running=247ms late=64ms h=android.app.ActivityThread$H w=110) (msgIndex=4 wall=275ms seq=4 running=251ms runnable=2ms late=326ms h=android.app.ActivityThread$H w=159)
2023-08-12 15:37:32.396 31840-31885 libMEOW                 com.example.sudokusolver             D  applied 1 plugins for [com.example.sudokusolver]:
2023-08-12 15:37:32.396 31840-31885 libMEOW                 com.example.sudokusolver             D    plugin 1: [libMEOW_gift.so]:
2023-08-12 15:37:32.401 31840-31885 GED                     com.example.sudokusolver             I  [GT]_get_procNameprocess pid(31840)
2023-08-12 15:37:32.401 31840-31885 GED                     com.example.sudokusolver             I  [GT]_getprocess name(com.example.sudokusolver)
2023-08-12 15:37:32.401 31840-31885 le.sudokusolve          com.example.sudokusolver             I  [GT] ret(1) gt_status(00000000) aniso_debug_level(0) gt_aniso_max_level(16) ani so mask(00000001) tri mask(00000002)
2023-08-12 15:37:32.401 31840-31885 libMEOW_gift            com.example.sudokusolver             I  ctx:0xb400007c69ca2ee8, ARC not Enabled.
2023-08-12 15:37:32.413 31840-31885 ion                     com.example.sudokusolver             E  ioctl c0044901 failed with code -1: Invalid argument
2023-08-12 15:37:33.760 31840-31876 System                  com.example.sudokusolver             W  A resource failed to call close. 
2023-08-12 15:37:33.761 31840-31876 System                  com.example.sudokusolver             W  A resource failed to call close. 
2023-08-12 15:37:34.299 31840-31840 ViewRootImpl[]          com.example.sudokusolver             D  hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
2023-08-12 15:37:34.307 31840-31840 InputTransport          com.example.sudokusolver             I  Create ARC handle: 0xb400007d005f60e0
2023-08-12 15:37:34.397 31840-31885 GED                     com.example.sudokusolver             I  ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 42, oppidx_max 42, oppidx_min 0
2023-08-12 15:37:34.896 31840-31840 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:37:34.904 31840-31840 View                    com.example.sudokusolver             D  [Warning] assignParent to null: this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:37:34.910 31840-31840 InputTransport          com.example.sudokusolver             I  Destroy ARC handle: 0xb400007c589ddb20
2023-08-12 15:37:39.939 31840-31840 Service                 com.example.sudokusolver             D  SERVICE STARTED
2023-08-12 15:37:39.940 31840-31909 clicked                 com.example.sudokusolver             D  click
2023-08-12 15:37:39.941 31840-31840 Compatibil...geReporter com.example.sudokusolver             D  Compat change id reported: 147798919; UID 10496; state: ENABLED
2023-08-12 15:37:40.063 31840-31883 le.sudokusolve          com.example.sudokusolver             I  ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
2023-08-12 15:38:01.512 31840-31840 le.sudokusolver         com.example.sudokusolver             W  type=1400 audit(0.0:137797): avc: granted { execute } for path="/data/data/com.example.sudokusolver/code_cache/startup_agents/31c79e06-agent.so" dev="dm-11" ino=618782 scontext=u:r:untrusted_app:s0:c240,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c240,c257,c512,c768 tclass=file app=com.example.sudokusolver
2023-08-12 15:38:01.524 31840-31840 studio.deploy           com.example.sudokusolver             V  Prior agent invocations in this VM: 0
2023-08-12 15:38:01.547 31840-31840 studio.deploy           com.example.sudokusolver             I  Using Structure Redefinition Extension
2023-08-12 15:38:01.553 29979-29979 studio.deploy           pid-29979                            E  Could not remove dir '/data/data/com.example.sudokusolver/code_cache/.ll/': No such file or directory
2023-08-12 15:38:05.980 31840-31885 OpenGLRenderer          com.example.sudokusolver             D  endAllActiveAnimators on 0xb400007c0b85b700 (RippleDrawable) with handle 0xb400007c69c18040
2023-08-12 15:38:05.981 31840-31840 View                    com.example.sudokusolver             D  [Warning] assignParent to null: this = android.widget.FrameLayout{bbe7467 V.E...... ........ 0,0-550,165}
2023-08-12 15:38:05.995 31840-31840 InputTransport          com.example.sudokusolver             I  Destroy ARC handle: 0xb400007d005f60e0
2023-08-12 15:38:05.996 31840-31840 Service                 com.example.sudokusolver             D  SERVICE STARTED
2023-08-12 15:38:08.852  2142-2142  ActivityManagerWrapper  pid-2142                             E  getRecentTasks: taskId=154   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sudokusolver/.MainActivity }
---------------------------- PROCESS ENDED (31840) for package com.example.sudokusolver ----------------------------
2023-08-12 15:38:10.792 29979-29979 studio.deploy           pid-29979                            E  Could not remove dir '/data/data/com.example.sudokusolver/code_cache/.ll/': No such file or directory
---------------------------- PROCESS STARTED (31982) for package com.example.sudokusolver ----------------------------
2023-08-12 15:38:11.195 31982-31982 ActivityThread          com.example.sudokusolver             W  Application com.example.sudokusolver can be debugged on port 8100...
2023-08-12 15:38:11.206 31982-31982 le.sudokusolve          com.example.sudokusolver             W  ClassLoaderContext classpath size mismatch. expected=0, found=1 (PCL[] | PCL[/data/data/com.example.sudokusolver/code_cache/.overlay/base.apk/classes4.dex*127293272])
2023-08-12 15:38:11.207 31982-31982 le.sudokusolve          com.example.sudokusolver             W  Found duplicate classes, falling back to extracting from APK : /data/app/~~SulUYZxd5YnqTvrkNbJQdw==/com.example.sudokusolver-W8DCKxBEqhN-8T7rr30ACQ==/base.apk
2023-08-12 15:38:11.207 31982-31982 le.sudokusolve          com.example.sudokusolver             W  NOTE: This wastes RAM and hurts startup performance.
2023-08-12 15:38:11.207 31982-31982 le.sudokusolve          com.example.sudokusolver             W  Found duplicated class when checking oat files: 'Lcom/example/sudokusolver/AutoService$1;' in /data/data/com.example.sudokusolver/code_cache/.overlay/base.apk/classes4.dex and /data/app/~~SulUYZxd5YnqTvrkNbJQdw==/com.example.sudokusolver-W8DCKxBEqhN-8T7rr30ACQ==/base.apk!classes4.dex
2023-08-12 15:38:11.431 31982-31982 NetworkSecurityConfig   com.example.sudokusolver             D  No Network Security Config specified, using platform default
2023-08-12 15:38:11.432 31982-31982 NetworkSecurityConfig   com.example.sudokusolver             D  No Network Security Config specified, using platform default
2023-08-12 15:38:11.436 31982-31982 libc                    com.example.sudokusolver             E  Access denied finding property "ro.vendor.pref_scale_resolution"
2023-08-12 15:38:11.467 31982-32015 libMEOW                 com.example.sudokusolver             D  meow reload base cfg path: na
2023-08-12 15:38:11.467 31982-32015 libMEOW                 com.example.sudokusolver             D  meow reload overlay cfg path: na
2023-08-12 15:38:11.469 31982-32015 libMEOW                 com.example.sudokusolver             D  applied 1 plugins for [com.example.sudokusolver]:
2023-08-12 15:38:11.469 31982-32015 libMEOW                 com.example.sudokusolver             D    plugin 1: [libMEOW_gift.so]:
2023-08-12 15:38:11.513 31982-31982 AppCompatDelegate       com.example.sudokusolver             D  Checking for metadata for AppLocalesMetadataHolderService : Service not found
2023-08-12 15:38:11.543 31982-31982 View                    com.example.sudokusolver             D  com.example.sudokusolver initForcedUseForceDark: 1
2023-08-12 15:38:11.553 31982-31982 DecorView[]             com.example.sudokusolver             D  getWindowModeFromSystem  windowmode is 1
2023-08-12 15:38:11.553 31982-31982 DecorView               com.example.sudokusolver             D  createDecorCaptionView windowingMode:1 mWindowMode 1 isFullscreen: true
2023-08-12 15:38:11.616 31982-31982 le.sudokusolve          com.example.sudokusolver             W  Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2023-08-12 15:38:11.616 31982-31982 le.sudokusolve          com.example.sudokusolver             W  Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2023-08-12 15:38:11.721 31982-31982 SurfaceFactory          com.example.sudokusolver             I  [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@6e07aeb
2023-08-12 15:38:11.728 31982-31982 ViewRootIm...nActivity] com.example.sudokusolver             D  hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
2023-08-12 15:38:11.732 31982-31982 libMEOW                 com.example.sudokusolver             D  applied 1 plugins for [com.example.sudokusolver]:
2023-08-12 15:38:11.732 31982-31982 libMEOW                 com.example.sudokusolver             D    plugin 1: [libMEOW_gift.so]:
2023-08-12 15:38:11.732 31982-31982 InputTransport          com.example.sudokusolver             I  Create ARC handle: 0xb400007c589e1bc0
2023-08-12 15:38:11.735 31982-31982 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:38:11.736 31982-31982 Looper                  com.example.sudokusolver             W  PerfMonitor looperActivity : package=com.example.sudokusolver/.MainActivity time=282ms latency=329ms running=254ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.LaunchActivityItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem } historyMsgCount=3 (msgIndex=1 wall=67ms seq=1 running=63ms late=2ms h=android.app.ActivityThread$H w=162) (msgIndex=3 wall=270ms seq=3 running=253ms late=61ms h=android.app.ActivityThread$H w=110)
2023-08-12 15:38:11.736 31982-31982 Looper                  com.example.sudokusolver             W  PerfMonitor looperActivity : package=com.example.sudokusolver/.MainActivity time=0ms latency=612ms running=0ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] } historyMsgCount=4 (msgIndex=1 wall=67ms seq=1 running=63ms late=2ms h=android.app.ActivityThread$H w=162) (msgIndex=3 wall=270ms seq=3 running=253ms late=61ms h=android.app.ActivityThread$H w=110) (msgIndex=4 wall=282ms seq=4 running=254ms runnable=1ms late=329ms h=android.app.ActivityThread$H w=159)
2023-08-12 15:38:11.765 31982-32008 libMEOW                 com.example.sudokusolver             D  applied 1 plugins for [com.example.sudokusolver]:
2023-08-12 15:38:11.765 31982-32008 libMEOW                 com.example.sudokusolver             D    plugin 1: [libMEOW_gift.so]:
2023-08-12 15:38:11.771 31982-32008 GED                     com.example.sudokusolver             I  [GT]_get_procNameprocess pid(31982)
2023-08-12 15:38:11.771 31982-32008 GED                     com.example.sudokusolver             I  [GT]_getprocess name(com.example.sudokusolver)
2023-08-12 15:38:11.771 31982-32008 le.sudokusolve          com.example.sudokusolver             I  [GT] ret(1) gt_status(00000000) aniso_debug_level(0) gt_aniso_max_level(16) ani so mask(00000001) tri mask(00000002)
2023-08-12 15:38:11.771 31982-32008 libMEOW_gift            com.example.sudokusolver             I  ctx:0xb400007c69ca2ee8, ARC not Enabled.
2023-08-12 15:38:11.784 31982-32008 ion                     com.example.sudokusolver             E  ioctl c0044901 failed with code -1: Invalid argument
2023-08-12 15:38:12.801  2142-2142  ActivityManagerWrapper  pid-2142                             E  getRecentTasks: taskId=155   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sudokusolver/.MainActivity }
2023-08-12 15:38:12.845  2142-2142  ActivityManagerWrapper  pid-2142                             E  getRecentTasks: taskId=155   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sudokusolver/.MainActivity }
2023-08-12 15:38:13.121 31982-32001 System                  com.example.sudokusolver             W  A resource failed to call close. 
2023-08-12 15:38:13.121 31982-32001 System                  com.example.sudokusolver             W  A resource failed to call close. 
2023-08-12 15:38:13.349 31982-32008 GED                     com.example.sudokusolver             I  ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 42, oppidx_max 42, oppidx_min 0
2023-08-12 15:38:13.359 31982-31982 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:38:19.421 31982-32006 le.sudokusolve          com.example.sudokusolver             I  ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
2023-08-12 15:38:26.789  2142-2142  ActivityManagerWrapper  pid-2142                             E  getRecentTasks: taskId=155   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sudokusolver/.MainActivity }
2023-08-12 15:38:26.795  2142-2142  ActivityManagerWrapper  pid-2142                             E  getRecentTasks: taskId=155   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sudokusolver/.MainActivity }
2023-08-12 15:38:26.840  2142-2142  ActivityManagerWrapper  pid-2142                             E  getRecentTasks: taskId=155   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sudokusolver/.MainActivity }
2023-08-12 15:38:27.297 31982-31982 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:38:27.301 31982-31982 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:38:27.967 31982-31982 ViewRootImpl[]          com.example.sudokusolver             D  hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
2023-08-12 15:38:27.974 31982-31982 InputTransport          com.example.sudokusolver             I  Create ARC handle: 0xb400007c63937f20
2023-08-12 15:38:28.697 31982-31982 PhoneWindow             com.example.sudokusolver             V  DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@3c9dac7, this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:38:28.701 31982-31982 View                    com.example.sudokusolver             D  [Warning] assignParent to null: this = DecorView@a84f8f4[MainActivity]
2023-08-12 15:38:28.704 31982-31982 InputTransport          com.example.sudokusolver             I  Destroy ARC handle: 0xb400007c589e1bc0
2023-08-12 15:38:28.736 31982-31982 Service                 com.example.sudokusolver             D  SERVICE STARTED
2023-08-12 15:38:28.737 31982-32059 SCREENSHOT                 com.example.sudokusolver             D  Starting
2023-08-12 15:38:28.737 31982-32059 SCREENSHOT              com.example.sudokusolver             D  trying to capture
2023-08-12 15:38:28.737 31982-31982 Compatibil...geReporter com.example.sudokusolver             D  Compat change id reported: 147798919; UID 10496; state: ENABLED
2023-08-12 15:38:28.745 31982-31982 SCREENSHOT              com.example.sudokusolver             D  Failed 1

从 TakeScreenshotCallback() 方法的结果来看,它返回了 int 错误代码 1,Android studio 网站上说该错误代码意味着内部错误,但是是什么导致了内部错误?

java android accessibility screenshot accessibilityservice
1个回答
0
投票

这可能是由于多种原因造成的,例如Android系统中的错误、设备硬件问题或应用程序实现问题。您可能想尝试在不同的设备或模拟器上运行您的应用程序,看看问题是否仍然存在。

如果错误仍然发生,则尝试调试以查看其实现中是否有任何错误。

此外,日志显示存在有关 ClassLoaderContext 类路径大小不匹配的警告和有关发现重复类的警告1。这些警告表明您的应用程序的设置或构建方式可能存在问题。

检查日志的前三行:

W ClassLoaderContext 类路径大小不匹配

W 发现重复的类,退回到从 APK 中提取

© www.soinside.com 2019 - 2024. All rights reserved.