Q-testing
Q-testing copied to clipboard
ImportError: No module named ActionConstValue
Thanks for releasing this useful tool!
I followed the setup instructions and successfully ran the tool. But I note one exception is always throwing. I attached the log info below. Can you give any clue? Thanks a lot!
I ran Q-testing on Android 6.0 and this exception happens deterministically when I set TIME_LIMIT
as 300
(i.e., 5 mins, Q-tseting stops with this exception when the time limit is reached) or 21600
(i.e., 6 hours, Q-testing stops after running only 2 hours)
========episode 499_9========
the action_table is empty since it has never been visited before
the selected action string is 4@clickLong(content-desc='No suggestion'):android.widget.TextView@""
view_string is: android.widget.TextView@""
the executation cmd is: timeout 2s python /home/tingsu/Projects/android-app-bugs-dataset/tools/Q-testing/Q-testing/events/long_click_by_content_desc.py emulator-5554 'No suggestion'
info is mCurrentFocus=Window{1e95b9c u0 com.ichi2.anki/com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity}^M
current_activity_name is: com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity
the element important is android.widget.LinearLayout
the element important is android.widget.FrameLayout
q-current is assigned with 0
the updated action is 4@clickLong(content-desc='No suggestion'):android.widget.TextView@""
q_current is 0
q_next is 1000.0
q_current for action 4@clickLong(content-desc='No suggestion'):android.widget.TextView@""
is 49.0
the jumped state is com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity
episode 500 discover activities:
com.ichi2.anki.DeckPicker
com.ichi2.anki.Statistics
com.ichi2.anki.FilteredDeckOptions
com.android.launcher3.Launcher
com.ichi2.anki.StudyOptionsActivity
com.ichi2.anki.ModelBrowser
com.google.android.velvet.ui.settings.SettingsActivity
com.ichi2.anki.Preferences
com.android.browser.BrowserActivity
com.ichi2.anki.NoteEditor
com.ichi2.anki.CardBrowser
com.ichi2.anki.ModelFieldEditor
com.ichi2.anki.CardTemplateEditor
com.ichi2.anki.MyAccount
com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity
com.android.camera.Camera
com.ichi2.anki.DeckOptions
com.google.android.gm.welcome.WelcomeTourActivity
com.ichi2.anki.Info
com.ichi2.anki.Previewer
com.ichi2.anki.Reviewer
com.ichi2.anki.multimediacard.activity.LoadPronounciationActivity
com.google.android.apps.photos.picker.external.ExternalPickerActivity
===========time information===========
total time is: 6997.29711199
time_get_state is: 2894.91255379
time_get_action is: 1.23758792877
time_execute_action is: 3986.96231842
time_get_reward is: 78.1650059223
time_update_qtable is: 0.945386171341
time_calculate_coverage is: 0.0
===========memory buffer information===========
the states size in com.ichi2.anki.DeckPicker is 84
the states size in com.ichi2.anki.multimediacard.activity.LoadPronounciationActivity is 2
the states size in com.ichi2.anki.Info is 2
the states size in com.ichi2.anki.CardBrowser is 34
the states size in com.ichi2.anki.NoteEditor is 70
the states size in com.android.camera.Camera is 1
the states size in com.ichi2.anki.DeckOptions is 45
the states size in com.google.android.gm.welcome.WelcomeTourActivity is 1
the states size in com.ichi2.anki.FilteredDeckOptions is 36
the states size in com.ichi2.anki.ModelBrowser is 34
the states size in com.ichi2.anki.ModelFieldEditor is 29
the states size in com.google.android.apps.photos.picker.external.ExternalPickerActivity is 1
the states size in com.ichi2.anki.StudyOptionsActivity is 13
the states size in com.ichi2.anki.MyAccount is 5
the states size in com.android.launcher3.Launcher is 1
the states size in com.ichi2.anki.Preferences is 63
the states size in com.ichi2.anki.Reviewer is 17
the states size in com.google.android.velvet.ui.settings.SettingsActivity is 2
the states size in com.ichi2.anki.CardTemplateEditor is 61
the states size in com.android.browser.BrowserActivity is 6
the states size in com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity is 7
the states size in com.ichi2.anki.Previewer is 4
the states size in com.ichi2.anki.Statistics is 15
total states number in memory buffer is: 533
===========Q-table information===========
total states number in Q-table is: 413
===========step information===========
total number is: 5000
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ActionConstValue
Action returned -1
I encountered another exception. I am using Android 6.0. Any clue? It says length is smaller than 40:<hierarchy rotation="0" />
. Thanks a lot in advance.
==================================================================================================
Total params: 126,000
Trainable params: 126,000
Non-trainable params: 0
__________________________________________________________________________________________________
==============episode 0_=============
info is mCurrentFocus=Window{3dc7e97 u0 com.ichi2.anki/com.ichi2.anki.DeckPicker}
current_activity_name is: com.ichi2.anki.DeckPicker
length is smaller than 40:<hierarchy rotation="0" />
========episode 0_0========
Traceback (most recent call last):
File "<string>", line 326, in <module>
File "<string>", line 280, in main
File "/home/tim/PyCharmProject/Q-testing/Q-testing/qlearning_final_coverage_multi.py", line 901, in qlearning_loop
File "/home/tim/PyCharmProject/Q-testing/Q-testing/qlearning_final_coverage_multi.py", line 525, in get_action
File "/home/tim/PyCharmProject/Q-testing/Q-testing/qlearning_final_coverage_multi.py", line 424, in get_random_action
File "/home/tim/PyCharmProject/Q-testing/Q-testing/event_extractor/event_extractor.py", line 58, in extract_event
NameError: global name 'exit' is not defined
main returned -1
Thanks for releasing this useful tool!
I followed the setup instructions and successfully ran the tool. But I note one exception is always throwing. I attached the log info below. Can you give any clue? Thanks a lot!
I ran Q-testing on Android 6.0 and this exception happens deterministically when I set
TIME_LIMIT
as300
(i.e., 5 mins, Q-tseting stops with this exception when the time limit is reached) or21600
(i.e., 6 hours, Q-testing stops after running only 2 hours)========episode 499_9======== the action_table is empty since it has never been visited before the selected action string is 4@clickLong(content-desc='No suggestion'):android.widget.TextView@"" view_string is: android.widget.TextView@"" the executation cmd is: timeout 2s python /home/tingsu/Projects/android-app-bugs-dataset/tools/Q-testing/Q-testing/events/long_click_by_content_desc.py emulator-5554 'No suggestion' info is mCurrentFocus=Window{1e95b9c u0 com.ichi2.anki/com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity}^M current_activity_name is: com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity the element important is android.widget.LinearLayout the element important is android.widget.FrameLayout q-current is assigned with 0 the updated action is 4@clickLong(content-desc='No suggestion'):android.widget.TextView@"" q_current is 0 q_next is 1000.0 q_current for action 4@clickLong(content-desc='No suggestion'):android.widget.TextView@"" is 49.0 the jumped state is com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity episode 500 discover activities: com.ichi2.anki.DeckPicker com.ichi2.anki.Statistics com.ichi2.anki.FilteredDeckOptions com.android.launcher3.Launcher com.ichi2.anki.StudyOptionsActivity com.ichi2.anki.ModelBrowser com.google.android.velvet.ui.settings.SettingsActivity com.ichi2.anki.Preferences com.android.browser.BrowserActivity com.ichi2.anki.NoteEditor com.ichi2.anki.CardBrowser com.ichi2.anki.ModelFieldEditor com.ichi2.anki.CardTemplateEditor com.ichi2.anki.MyAccount com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity com.android.camera.Camera com.ichi2.anki.DeckOptions com.google.android.gm.welcome.WelcomeTourActivity com.ichi2.anki.Info com.ichi2.anki.Previewer com.ichi2.anki.Reviewer com.ichi2.anki.multimediacard.activity.LoadPronounciationActivity com.google.android.apps.photos.picker.external.ExternalPickerActivity ===========time information=========== total time is: 6997.29711199 time_get_state is: 2894.91255379 time_get_action is: 1.23758792877 time_execute_action is: 3986.96231842 time_get_reward is: 78.1650059223 time_update_qtable is: 0.945386171341 time_calculate_coverage is: 0.0 ===========memory buffer information=========== the states size in com.ichi2.anki.DeckPicker is 84 the states size in com.ichi2.anki.multimediacard.activity.LoadPronounciationActivity is 2 the states size in com.ichi2.anki.Info is 2 the states size in com.ichi2.anki.CardBrowser is 34 the states size in com.ichi2.anki.NoteEditor is 70 the states size in com.android.camera.Camera is 1 the states size in com.ichi2.anki.DeckOptions is 45 the states size in com.google.android.gm.welcome.WelcomeTourActivity is 1 the states size in com.ichi2.anki.FilteredDeckOptions is 36 the states size in com.ichi2.anki.ModelBrowser is 34 the states size in com.ichi2.anki.ModelFieldEditor is 29 the states size in com.google.android.apps.photos.picker.external.ExternalPickerActivity is 1 the states size in com.ichi2.anki.StudyOptionsActivity is 13 the states size in com.ichi2.anki.MyAccount is 5 the states size in com.android.launcher3.Launcher is 1 the states size in com.ichi2.anki.Preferences is 63 the states size in com.ichi2.anki.Reviewer is 17 the states size in com.google.android.velvet.ui.settings.SettingsActivity is 2 the states size in com.ichi2.anki.CardTemplateEditor is 61 the states size in com.android.browser.BrowserActivity is 6 the states size in com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity is 7 the states size in com.ichi2.anki.Previewer is 4 the states size in com.ichi2.anki.Statistics is 15 total states number in memory buffer is: 533 ===========Q-table information=========== total states number in Q-table is: 413 ===========step information=========== total number is: 5000 Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named ActionConstValue Action returned -1
Some follow-ups:
I ran Q-tseting on Ubuntu 16.04, 18.04, 20.04, Android 4.4 / Android 6.0 / Android 7.1 / Android 9.0, and set TIME_LIMIT
as 5 mins or 2 hours, this exception always happens.
Could this issue be caused by some issues when packaging the source code into an executable ? Any plan to look into this issue? Thanks.
I encountered another exception. I am using Android 6.0. Any clue? It says
length is smaller than 40:<hierarchy rotation="0" />
. Thanks a lot in advance.================================================================================================== Total params: 126,000 Trainable params: 126,000 Non-trainable params: 0 __________________________________________________________________________________________________ ==============episode 0_============= info is mCurrentFocus=Window{3dc7e97 u0 com.ichi2.anki/com.ichi2.anki.DeckPicker} current_activity_name is: com.ichi2.anki.DeckPicker length is smaller than 40:<hierarchy rotation="0" /> ========episode 0_0======== Traceback (most recent call last): File "<string>", line 326, in <module> File "<string>", line 280, in main File "/home/tim/PyCharmProject/Q-testing/Q-testing/qlearning_final_coverage_multi.py", line 901, in qlearning_loop File "/home/tim/PyCharmProject/Q-testing/Q-testing/qlearning_final_coverage_multi.py", line 525, in get_action File "/home/tim/PyCharmProject/Q-testing/Q-testing/qlearning_final_coverage_multi.py", line 424, in get_random_action File "/home/tim/PyCharmProject/Q-testing/Q-testing/event_extractor/event_extractor.py", line 58, in extract_event NameError: global name 'exit' is not defined main returned -1
I encountered this issue before installing uiautomator. In my case the problem has been fixed after running pip install uiautomator==0.3.6
.
Thanks for the comments, @RichardHoOoOo !
I double checked my environment. I already installed the requirement pip install uiautomator==0.3.6
. But this error still appears.
I have tried on different OS and Android versions. Can I know your running environment (e.g., OS, Android, and python version)? Thanks a lot!
Hi @tingsu , I am running on CentOS 8 stream, Android emulator running Android 7.0, Python 3.6.8. BTW, I can encounter this error again if I don't set <my_home_dir>/.local/bin on PATH, which is where pip
is installed. I don't know if this can help, I am also trying this tool.
Thanks! So you run the tool with Python 3.6.8? I suppose the tool requires Python 2.7. If I run the tool with Python3, it will throw some other exceptions. Btw, can i know how long did you try to run this tool? (hours? or minutes?)
Hi @tingsu , may I get back to you tomorrow? So far I have just run this tool on 1 apk for 1min, let me see what happens after testing more apks for at least 1 hour.
Good, thanks!
"ImportError: No module named **" is introduced when packaged with 'pyinstaller'. However, it does not influence the execution of Q-testing. You can just let it go, or wait for us to find the root reason and fix it.
Thanks for the reply. I set the testing time as 6 hours per app. Q-testing stops with this exception in most cases (usually when the tool runs for 2-3 hours). I am not sure what the root cause is. Hope my observation could help you.