honeynet / droidbot

A lightweight test input generator for Android. Similar to Monkey, but with more intelligence and cool features!
MIT License
791 stars 229 forks source link

AttributeError: 'NoneType' object has no attribute 'state_str' #93

Closed GrayR00t closed 3 years ago

GrayR00t commented 5 years ago

While running frozzen_bubble game apk file in -cv mode I got this error message

Traceback (most recent call last): File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/device.py", line 815, in get_current_state screenshot_path=screenshot_path) File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/device_state.py", line 27, in init self.__assemble_view_tree(self.view_tree, self.views) File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/device_state.py", line 64, in assemble_view_tree self.view_tree = copy.deepcopy(views[0]) IndexError: list index out of range WARNING:Device:Failed to get current state! WARNING:UtgGreedySearchPolicy:exception during sending events: 'NoneType' object has no attribute 'state_str' Traceback (most recent call last): File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/input_policy.py", line 69, in start input_manager.add_event(event) File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/input_manager.py", line 98, in add_event event_log.start() File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/input_event.py", line 231, in start self.event_str = self.event.get_event_str(self.from_state) File "/home/pattinson/My_Lab/Droidbot/droidbot/droidbot/input_event.py", line 365, in get_event_str return "%s(state=%s, name=%s)" % (self.class.name__, state.state_str, self.name) AttributeError: 'NoneType' object has no attribute 'state_str' WARNING:Minicap:last_screen is None WARNING:Device:Failed to get views using OpenCV. WARNING:DroidBotAppConn:last_acc_event is None, waiting WARNING:DroidBotAppConn:last_acc_event is None, waiting WARNING:DroidBotAppConn:last_acc_event is None, waiting WARNING:DroidBotAppConn:last_acc_event is None, waiting WARNING:DroidBotAppConn:last_acc_event is None, waiting WARNING:DroidBotAppConn:last_acc_event is None, waiting WARNING:DroidBotAppConn:cannot get non-None last_acc_event WARNING:Device:Failed to get views using Accessibility. WARNING:Device:failed to get current views! WARNING:Device:exception in get_current_state: list index out of range

yuanchun-li commented 5 years ago

Could you please provide details about what command(s) you are using? Also can you post the log output of running the code without -cv option?

GrayR00t commented 5 years ago

droidbot -a FrozenBubble-debug.apk -o ./frozen_bubble1 ---without cv mode

droidbot -cv -a FrozenBubble-debug.apk -o ./frozen_bubble1 ----with cv mode

GrayR00t commented 5 years ago

droidbot -a FrozenBubble-debug.apk -o ./frozen_bubble1 INFO:DroidBot:Starting DroidBot INFO:Device:waiting for device PID: 8002 INFO: Using projection 720x1280@720x1280/0 INFO: (external/MY_minicap/src/minicap_25.cpp:241) Creating SurfaceComposerClient INFO: (external/MY_minicap/src/minicap_25.cpp:244) Performing SurfaceComposerClient init check INFO: (external/MY_minicap/src/minicap_25.cpp:251) Creating virtual display INFO: (external/MY_minicap/src/minicap_25.cpp:257) Creating buffer queue INFO: (external/MY_minicap/src/minicap_25.cpp:262) Creating CPU consumer INFO: (external/MY_minicap/src/minicap_25.cpp:266) Creating frame waiter INFO: (external/MY_minicap/src/minicap_25.cpp:270) Publishing virtual display INFO: (external/MY_minicap/src/minicap_25.cpp:287) Found 7.1 Developer Preview SurfaceComposerClient::setDisplaySurface INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 2766852 bytes for JPG encoder INFO: (external/MY_minicap/src/minicap_25.cpp:308) Destroying virtual display [CONNECTION] TelnetConsole is not enabled. [CONNECTION] DroidBotIme is enabled and connected. [CONNECTION] DroidBotAppConn is enabled and connected. [CONNECTION] UserInputMonitor is enabled and connected. [CONNECTION] Minicap is enabled but not connected. [CONNECTION] ProcessMonitor is enabled and connected. [CONNECTION] ADB is enabled and connected. [CONNECTION] Logcat is enabled and connected. INFO:Device:App installed: org.jfedor.frozenbubble INFO:Device:Main activity: org.jfedor.frozenbubble..FrozenBubble INFO:AppEnvManager:Start deploying environment, policy is none INFO:InputEventManager:start sending events, policy is dfs_greedy Input: KeyEvent(state=be1a3e6301067678e9ac512afe787684, name=HOME) Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 8ddc0749e12380164b8e0fd380b1cc07 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=2d736a17525ced0359790cec3ec735c1, view=6a90ff0e6dd89a4a5f9ff7bf0c2ba4a8) WARNING:Device:cannot write mode RGBA as JPEG INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=2d736a17525ced0359790cec3ec735c1, view=c7201edaeb2b2d6d58ec6a20ffd09303) WARNING:Device:cannot write mode RGBA as JPEG INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=2d736a17525ced0359790cec3ec735c1, view=542852771b8a55592d1808038ad9b093) WARNING:Device:cannot write mode RGBA as JPEG INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 2d736a17525ced0359790cec3ec735c1 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=2d736a17525ced0359790cec3ec735c1, view=8a51df44979a0686b22f0515b4c99492) WARNING:Device:cannot write mode RGBA as JPEG INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=4fc351e2dddc0a767887015dbe7a07c2, view=6a90ff0e6dd89a4a5f9ff7bf0c2ba4a8) INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=4fc351e2dddc0a767887015dbe7a07c2, view=c7201edaeb2b2d6d58ec6a20ffd09303) INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=4fc351e2dddc0a767887015dbe7a07c2, view=542852771b8a55592d1808038ad9b093) INFO:UtgGreedySearchPolicy:Current state: 4fc351e2dddc0a767887015dbe7a07c2 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist. INFO:UtgGreedySearchPolicy:Current state: a3e02b1f10c5db22cc561b7610b39605 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=a3e02b1f10c5db22cc561b7610b39605, view=6a90ff0e6dd89a4a5f9ff7bf0c2ba4a8) INFO:UtgGreedySearchPolicy:Current state: a3e02b1f10c5db22cc561b7610b39605 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble') Error type 3 Error: Activity class {org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble} does not exist.

yzygitzh commented 5 years ago

Hi, Just fixed some bugs in cv module. Tested the app using Google Nexus 5 and Android emulator with Android 7.1.2 and it worked fine. In the output you provided, it seems that there are redundant dots in "org.jfedor.frozenbubble/org.jfedor.frozenbubble..FrozenBubble". It should be "org.jfedor.frozenbubble/org.jfedor.frozenbubble.FrozenBubble" instead. I'm not able to reproduce it though...you can submit a PR if you find the root cause of the problem. Thanks!

RicardoUW commented 5 years ago

Hello, I tested droidbot with almost 50 Android apps from a database, and I got the Error type 3 in almost all of the apps. As yzygitzh commented there is a bug with the double dot. To illustrate, tetris.chelle..Tetris.

I am trying to fix the bug, but I can not do it. I need help. Please

[CONNECTION] ADB is enabled and connected. [CONNECTION] TelnetConsole is not enabled. [CONNECTION] DroidBotAppConn is enabled and connected. [CONNECTION] Minicap is enabled and connected. [CONNECTION] Logcat is enabled and connected. [CONNECTION] UserInputMonitor is enabled and connected. [CONNECTION] ProcessMonitor is enabled and connected. [CONNECTION] DroidBotIme is enabled and connected. INFO:Device:App installed Ricardo: tetris.chelle INFO:Device:Main activity: tetris.chelle..Tetris INFO:AppEnvManager:Start deploying environment, policy is none INFO:InputEventManager:start sending events, policy is dfs_greedy Input: KeyEvent(state=1b8a77dbc75448c8bffd4bde62ae14d6, name=HOME) Input: IntentEvent(intent='am start tetris.chelle/tetris.chelle..Tetris') Error type 3 Error: Activity class {tetris.chelle/tetris.chelle..Tetris} does not exist. INFO:UtgGreedySearchPolicy:Current state: 1c7d118e0e0b59f2e1c4e0c3fc403626 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start tetris.chelle/tetris.chelle..Tetris') Error type 3 Error: Activity class {tetris.chelle/tetris.chelle..Tetris} does not exist. INFO:UtgGreedySearchPolicy:Current state: 2a2ee816e490b05bc1827449309b1cc7 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=2a2ee816e490b05bc1827449309b1cc7, view=01e5bd22b294b124601ba5f9f5038383) [I 16:17:03.637 NotebookApp] Saving file at /Untitled8.ipynb INFO:UtgGreedySearchPolicy:Current state: 2a2ee816e490b05bc1827449309b1cc7 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start tetris.chelle/tetris.chelle..Tetris') Error type 3 Error: Activity class {tetris.chelle/tetris.chelle..Tetris} does not exist. INFO:UtgGreedySearchPolicy:Current state: 2a2ee816e490b05bc1827449309b1cc7 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=2a2ee816e490b05bc1827449309b1cc7, view=46400092dac87e4f8d601ec6df90c6ff) INFO:UtgGreedySearchPolicy:Current state: 1b8a77dbc75448c8bffd4bde62ae14d6 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start tetris.chelle/tetris.chelle..Tetris') Error type 3 Error: Activity class {tetris.chelle/tetris.chelle..Tetris} does not exist. INFO:UtgGreedySearchPolicy:Current state: 1b8a77dbc75448c8bffd4bde62ae14d6 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=1b8a77dbc75448c8bffd4bde62ae14d6, view=f106f7dcf720aa26b032b43a3d4c9eda) INFO:UtgGreedySearchPolicy:Current state: df4db06272c3b1d4149a11411f532648 INFO:UtgGreedySearchPolicy:Trying to start the app... Input: IntentEvent(intent='am start tetris.chelle/tetris.chelle..Tetris') Error type 3 Error: Activity class {tetris.chelle/tetris.chelle..Tetris} does not exist. INFO:UtgGreedySearchPolicy:Current state: df4db06272c3b1d4149a11411f532648 INFO:UtgGreedySearchPolicy:The app had been restarted 1 times. INFO:UtgGreedySearchPolicy:Trying an unexplored event. Input: TouchEvent(state=df4db06272c3b1d4149a11411f532648, view=d2c1e4219fef0de024c89e68356d8e13) INFO:InputEventManager:Finish sending events [CONNECTION] ADB is disconnected Exception in thread Thread-4: Traceback (most recent call last): File "c:\users\ramanzan\appdata\local\programs\python\python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "c:\users\ramanzan\appdata\local\programs\python\python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "c:\users\ramanzan\droidbot\droidbot\adapter\minicap.py", line 163, in listen_messages chunk = bytearray(self.sock.recv(CHUNK_SIZE)) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

[CONNECTION] Logcat is disconnected [CONNECTION] UserInputMonitor is disconnected [CONNECTION] ProcessMonitor is disconnected [CONNECTION] DroidBotIme is disconnected INFO:DroidBot:DroidBot Stopped [I 16:19:03.638 NotebookApp] Saving file at /Untitled8.ipynb

yuanchun-li commented 3 years ago

Should have been fixed after upgrading androguard.