Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于AndroidManifest.xml每行读取的问题 #4

Open
kakakpy opened this issue Jan 17, 2020 · 1 comment
Open

对于AndroidManifest.xml每行读取的问题 #4

kakakpy opened this issue Jan 17, 2020 · 1 comment

Comments

@kakakpy
Copy link

kakakpy commented Jan 17, 2020

读行的话,
针对于AndroidManifest.xml的 换行配置读取错误:如

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
permission = re_per.findall(line)[0] IndexError: list index out of range

 with open(config.xml_path, 'r', encoding='utf-8') as file:
            lines = file.readlines()
            for line in lines:
                if line.find('package=') > -1:
                    re_name = re.compile(r"package=\"(.*?)\"\s")
                    sdkinfo.package_name = re_name.findall(line)[0]
                if line.find('versionName') > -1:
                    re_version = re.compile(r"versionName=\"(.*?)\"\s")
                    sdkinfo.version_name = re_version.findall(line)[0]
                if line.find('uses-permission') > -1:
                    re_per = re.compile(r"android:name=\"(.*?)\"\s")
                    permission = re_per.findall(line)[0]
                    sdkinfo.permissions.append(permission)
                if line.find('minSdkVersion') > -1:
                    re_min = re.compile(r"android:minSdkVersion=\"(.*?)\"\s")
                    sdkinfo.min_sdk_version = re_min.findall(line)[0]
                if line.find('targetSdkVersion') > -1:
                    re_target = re.compile(r"android:targetSdkVersion=\"(.*?)\"\s")
                    sdkinfo.target_sdk_version = re_target.findall(line)[0]
                if line.find("android:allowBackup") > -1:
                    re_allow = re.compile(r"android:allowBackup=\"(.*?)\"\s")
                    sdkinfo.allow_back_up = re_allow.findall(line)[0].lower() == "true"
                if line.find("android:debuggable") > -1:
                    re_debug = re.compile(r"android:debuggable=\"(.*?)\"\s")
                    sdkinfo.debuggable = re_debug.findall(line)[0].lower() == "true"
@lxzh
Copy link

lxzh commented Sep 15, 2020

    <uses-permission
        android:name="android.permission.READ_PHONE_STATE"
        android:maxSdkVersion="29" />

类似这种换行的读取就报错了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants