Repository: androguard/androguard
Issue: "AttributeError: 'NoneType' object has no attribute 'get_method_analysis' "  error occured while using AnalyzeAPK() in Androlyze.py -s

my python version :python 3.6.4
my installation method:
     git clone git@github.com:androguard/androguard.git 
     cd androguard
     pip3 install .

after installation i used androlyze.py . The whole screen output as follow:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
$ androlyze.py -s
Androguard version 3.1.0
In [1]:  a, d, dx = AnalyzeAPK("d:\\\\WorkSpace\\\\APKtool\\\\meiyingwifi.apk")

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
c:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\EGG-INFO\\scripts\\androl                                                                 yze.py in <module>()
----> 1 a, d, dx = AnalyzeAPK("d:\\\\WorkSpace\\\\APKtool\\\\meiyingwifi.apk")

C:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\androguard\\misc.py in A                                                                 nalyzeAPK(_file, session, raw)
     50             filename = _file
     51
---> 52     digest = session.add(filename, data)
     53     return session.get_objects_apk(filename, digest)
     54

C:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\androguard\\session.py i                                                                 n add(self, filename, raw_data, dx)
    164             dx = self.analyzed_vms.get(digest)
    165             for dex in dex_files:
--> 166                 _, d, dx = self.addDEX(filename, dex, dx)
    167         elif ret == "DEX":
    168             digest, d, _ = self.addDEX(filename, raw_data)

C:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\androguard\\session.py i                                                                 n addDEX(self, filename, data, dx)
    109         if self.export_ipython:
    110             log.debug("Exporting in ipython")
--> 111             d.create_python_export()
    112
    113         if dx is None:

C:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\androguard\\core\\bytecod                                                                 es\\dvm.py in create_python_export(self)
   8093
   8094         for _class in self.get_classes():
-> 8095             self._create_python_export_class(_class)
   8096
   8097     def _delete_python_export_class(self, _class):

C:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\androguard\\core\\bytecod                                                                 es\\dvm.py in _create_python_export_class(self, _class, delete)
   8110                 setattr(_class, "F", ExportObject())
   8111
-> 8112             self._create_python_export_methods(_class, delete)
   8113             self._create_python_export_fields(_class, delete)
   8114

C:\\python36\\lib\\site-packages\\androguard-3.1.0-py3.6.egg\\androguard\\core\\bytecod                                                                 es\\dvm.py in _create_python_export_methods(self, _class, delete)
   8122             setattr(method, "XT", ExportObject())
   8123
-> 8124             m_a = self.CM.get_vmanalysis().get_method_analysis(method)
   8125             if m_a:
   8126                 xrefs_from = m_a.get_xref_from()

AttributeError: 'NoneType' object has no attribute 'get_method_analysis'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

But it is okay to use function AnalyzeAPK() directly in program. 
So i debugged it only to find that changing "    CONF["SESSION"] = Session(True)" in line 52 of file androlyze.py to  "    CONF["SESSION"] = Session(False)"  can fix this problem. 
 but I don't know the reason.

Changed files:
androguard/session.py

diff --git a/androguard/session.py b/androguard/session.py
index 8c0e5a40..62541f01 100644
--- a/androguard/session.py
+++ b/androguard/session.py
@@ -106,10 +106,6 @@ class Session(object):
         self.analyzed_files[filename].append(digest)
         self.analyzed_digest[digest] = filename
 
-        if self.export_ipython:
-            log.debug("Exporting in ipython")
-            d.create_python_export()
-
         if dx is None:
             dx = Analysis()
 
@@ -121,6 +117,10 @@ class Session(object):
             d.set_vmanalysis(dx)
         self.analyzed_dex[digest] = dx
 
+        if self.export_ipython:
+            log.debug("Exporting in ipython")
+            d.create_python_export()
+
         return digest, d, dx
 
     def addDEY(self, filename, data, dx=None):