2016-05-12 42 views
2

此Kivy程序適用於我的Windows計算機,但不適用於將其與Buildozer打包並在Android上運行。在Android上它給人的錯誤:Android上的Kivy:urlopen錯誤[Errno 4]名稱解析中的不可恢復失敗

I/python (2173): <urlopen error [Errno 4] non-recoverable failure in name resolution.> 

這裏是程序:

from kivy.app import App 
from kivy.uix.label import Label 
import json 

try: 
    # For Python 3.x 
    from urllib.request import urlopen 
except ImportError: 
    # Fall back to Python 2's urllib2 
    from urllib2 import urlopen 

SETTINGS_URL = ('https://raw.githubusercontent.com/' 
       'SpotterRF/jekyll-updater/master/package.json') 


class MyApp(App): 

    def build(self): 
     response = urlopen(SETTINGS_URL) 
     file_bytes = response.read() 
     file_string = file_bytes.decode('utf-8') 
     settings_dict = json.loads(file_string) 

     return Label(text=settings_dict["name"]) 


MyApp().run() 

buildozer.specrequirements = fysom, uuid, dropbox, six, kivy, pytz, requests

全亞行日誌:

I/python (2173): ['/data/data/org.test.lanki/files/lib/python2.7/site-packages', '/data/data/org.test.lanki/files/lib/site-python'] 

I/python (2173): Android path ['/data/data/org.test.lanki/files/lib/python27.zip', '/data/data/org.test.lanki/files/lib/python2.7', '/data/data/org.test.lanki/files/lib/python2.7/lib-dynload', '/data/data/org.test.lanki/files/lib/python2.7/site-packages', '/data/data/org.test.lanki/files', '/data/data/org.test.lanki/files/_applibs'] 

I/python (2173): Android kivy bootstrap done. __name__ is __main__ 

I/python (2173): Run user program, change dir and execute main.py 

I/python (2173): [INFO    ] [Logger  ] Record log in /data/data/org.test.lanki/files/.kivy/logs/kivy_16-05-12_3.txt 

I/python (2173): [INFO    ] [Kivy  ] v1.9.0 

I/python (2173): [INFO    ] [Python  ] v2.7.2 (default, May 12 2016, 21:42:08) 

I/python (2173): [GCC 4.8] 

D/StatusBar.NetworkController(1213): onSignalStrengthsChanged signalStrength=SignalStrength: 99 99 -120 -160 -120 -1 -1 22 -101 -9 166 -1 2147483647 0x3000 gsm|lte level=3 

D/StatusBar.NetworkController(1213): updateTelephonySignalStrength: hasService=true ss=SignalStrength: 99 99 -120 -160 -120 -1 -1 22 -101 -9 166 -1 2147483647 0x3000 gsm|lte 

D/StatusBar.NetworkController(1213): updateTelephonySignalStrength: iconLevel=3 

D/StatusBar.NetworkController(1213): updateTelephonySignalStrength, No signal level. mPhoneSignalIconId = com.android.systemui:drawable/stat_sys_signal_3_auto_rotate mDataSignalIconId = com.android.systemui:drawable/stat_sys_signal_3_auto_rotate mQSPhoneSignalIconId = com.android.systemui:drawable/ic_qs_signal_3 mContentDescriptionPhoneSignal = Trois barres de signaux téléphoniques 

D/HeadsetPhoneState(3820): Signal level : previous=3 curr=3 

D/CustomFrequencyManagerService( 980): releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1958400 uid : 1000 pid : 980 tag : [email protected] 

D/CustomFrequencyManagerService( 980): FrequencyrequestList.getNextCStateDisableRequest, index: 5 

I/python (2173): [INFO    ] [Factory  ] 173 symbols loaded 

D/StatusBar.NetworkController(1213): refreshViews connected={ wifi } level=3 combinedSignalIconId=0x7f0205d9/com.android.systemui:drawable/stat_sys_wifi_signal_4 mobileLabel=Bell wifiLabel="Mawer" emergencyOnly=false combinedLabel="Mawer" mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f02052e/com.android.systemui:drawable/stat_sys_signal_3_auto_rotate mQSPhoneSignalIconId=0x7f020154/com.android.systemui:drawable/ic_qs_signal_3 mDataDirectionIconId=0x0/(null) mDataSignalIconId=0x7f02052e/com.android.systemui:drawable/stat_sys_signal_3_auto_rotate mDataTypeIconId=0x7f0203b8/com.android.systemui:drawable/stat_sys_data_connected_lte mQSDataTypeIconId=0x7f020157/com.android.systemui:drawable/ic_qs_signal_4g mNoSimIconId=0x0/(null) mWifiIconId=0x7f0205d9/com.android.systemui:drawable/stat_sys_wifi_signal_4 mQSWifiIconId=0x7f0202c7/com.android.systemui:drawable/qs_tile_wifi_signal_4 mWifiActivityIconId=0x7f020590/com.android.systemui:drawable/stat_sys_signal_no_inout mBluetoothTetherIconId=0x7f0205b6/com.android.systemui:drawable/stat_sys_tether_bluetooth 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshViews connected={ wifi } level=3 combinedSignalIconId=0x7f0205d9/com.android.systemui:drawable/stat_sys_wifi_signal_4 mobileLabel=Bell wifiLabel="Mawer" emergencyOnly=false combinedLabel="Mawer" mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f02052e/com.android.systemui:drawable/stat_sys_signal_3_auto_rotate mQSPhoneSignalIconId=0x7f020154/com.android.systemui:drawable/ic_qs_signal_3 mDataDirectionIconId=0x0/(null) mDataSignalIconId=0x7f02052e/com.android.systemui:drawable/stat_sys_signal_3_auto_rotate mDataTypeIconId=0x7f0203b8/com.android.systemui:drawable/stat_sys_data_connected_lte mQSDataTypeIconId=0x7f020157/com.android.systemui:drawable/ic_qs_signal_4g mNoSimIconId=0x0/(null) mWifiIconId=0x7f0205d9/com.android.systemui:drawable/stat_sys_wifi_signal_4 mQSWifiIconId=0x7f0202c7/com.android.systemui:drawable/qs_tile_wifi_signal_4 mWifiActivityIconId=0x7f02058b/com.android.systemui:drawable/stat_sys_signal_in mBluetoothTetherIconId=0x7f0205b6/com.android.systemui:drawable/stat_sys_tether_bluetooth 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

D/StatusBar.NetworkController(1213): refreshNwBoosterIndicator - setNWBoosterIndicators(false) 

I/python (2173): /data/data/org.test.lanki/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:13: RuntimeWarning: import cdrom: No module named cdrom 

I/python (2173): (ImportError: No module named cdrom) 

I/python (2173): [INFO    ] [Image  ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored) 

I/python (2173): [INFO    ] [Text  ] Provider: pygame 

I/python (2173): URL Error: Could not download settings json files. 

I/python (2173): <urlopen error [Errno 4] non-recoverable failure in name resolution.> 

I/WindowState( 980): WIN DEATH: Window{a154366 u0 d0 SurfaceView} 

I/SurfaceFlinger( 257): id=2635 Removed TurfaceView (5/8) 

W/InputDispatcher( 980): channel ~ Consumer closed input channel or an error occurred. events=0x9 

E/InputDispatcher( 980): channel ~ Channel is unrecoverably broken and will be disposed! 

I/SurfaceFlinger( 257): id=2635 Removed TurfaceView (-2/8) 

I/ActivityManager( 980): Process org.test.lanki:python (pid 2173)(adj 0) has died(104,346) 

D/ActivityManager( 980): isAutoRunBlockedApp:: org.test.lanki, Auto Run ON 

W/ActivityManager( 980): Force removing ActivityRecord{cdfb7ad u0 org.test.lanki/org.renpy.android.PythonActivity t14123}: app died, no saved state 

D/FocusedStackFrame( 980): Set to : 0 

I/WindowState( 980): WIN DEATH: Window{319fb08e u0 d0 org.test.lanki/org.renpy.android.PythonActivity} 
+0

權限來訪問互聯網被授予? (如果我沒有記錯,應該從cmd或buldozer文件中指定) – JustMe

+0

發佈完整的adb日誌。 – inclement

+2

還要確保你的要求中有openssl。這是使用https所必需的。 – inclement

回答

0

由於@JustMe和@inclement在他們的評論中指出,答案是如此修改buildozer.spec以下兩行存在:

  • android.permissions = INTERNET

  • openssl加到requirements線;在我的情況下,它變成了:
    requirements = fysom, uuid, dropbox, six, kivy, pytz, requests, openssl

相關問題