最新消息:20210917 已从crifan.com换到crifan.org

【未解决】安卓项目rcsjta的core运行报错:Perf Fail to get file list com.gsma.rcs getFolderSize Exception_1 java.lang.NullPointerException: Attempt to get length of null array

GET crifan 931浏览 0评论
折腾:
【未解决】Android Studio真机小米9中调试rcsjta的core的apk
期间,结果logcat中看到报错:
2020-08-04 16:05:39.122 6396-6436/com.gsma.rcs E/Perf: Fail to get file list com.gsma.rcs
2020-08-04 16:05:39.122 6396-6436/com.gsma.rcs E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Perf Fail to get file list
android – ANDR-PERF tryGetService failed; SELinux – Stack Overflow
android – Why do I get an error in an empty project? – Stack Overflow
感觉或许和之前的:
【无法解决】安卓项目rcsjta的core运行报错:type 1400 audit avc denied read for name object_r vendor_displayfeature_prop s0 dev tmpfs scontext tcontext tclass file permissive 0
暂时无法解决?也暂时可以不需要解决,可以忽略?
android – NullPointerException – Attempt to get length of null array (readDirectory()) – Stack Overflow
看看此处代码中是否有:listFiles
搜到3处:
src/com/gsma/rcs/core/ims/security/cert/KeyStoreManager.java
private static void addCertificates(Uri certificateFile) throws KeyStoreException, IOException {
    InputStream inStream = null;
    try {
        // Changed by Deutsche Telekom
        KeyStore ks = loadKeyStoreFromFile();
        final String certPath = certificateFile.getPath();
        File pathFile = new File(certPath);
        if (pathFile.isDirectory()) {
            File[] certificates = pathFile.listFiles(new FilenameFilter() {
                public boolean accept(File dir, String filename) {
                    return filename.endsWith(RcsSettingsData.CERTIFICATE_FILE_TYPE);
                }
            });
src/com/gsma/rcs/provider/UserProfilePersistedStorageUtil.java
/**
 * Get list of RCS accounts saved under the database directory
 * 
 * @param databasesDir the database directory
 * @return the array of RCS saved accounts (may be empty) or null
 */
private static File[] listOfSavedAccounts(final File databasesDir) {
    if (!databasesDir.exists() || !databasesDir.isDirectory()) {
        /*
         * As the database itself doesn't exist , So there won't be any accounts related to user
         * profile saved, So return from here. This is a special case where we don't throw
         * exception as backup and restore files and not always needed to be present and reading
         * information from persisted cache is always optional
         */
        return null;
    }
    FileFilter directoryFilter = new FileFilter() {
        @Override
        public boolean accept(File file) {
            return file.isDirectory()
                    && RCS_ACCOUNT_MATCH_PATTERN.matcher(file.getName()).matches();
        }
    };
    return databasesDir.listFiles(directoryFilter);
}
类似的:
tests/src/com/gsma/rcs/provider/UserProfilePersistedStorageUtilTest.java
/**
 * Pattern to check if rcs account have atleast 3 characters.
 */
private static final Pattern RCS_ACCOUNT_MATCH_PATTERN = Pattern.compile("^\\d{3,}$");


private static File[] listOfSavedAccounts(final File databasesDir) {
    if (!databasesDir.exists() || !databasesDir.isDirectory()) {
        /*
         * As the database itself doesn't exist , So there won't be any accounts related to user
         * profile saved, So return from here. This is a special case where we don't throw
         * exception as backup and restore files and not always needed to be present and reading
         * information from persisted cache is always optional
         */
        return null;
    }
    FileFilter directoryFilter = new FileFilter() {
        public boolean accept(File file) {
            return file.isDirectory()
                    && RCS_ACCOUNT_MATCH_PATTERN.matcher(file.getName()).matches();
        }
    };
    return databasesDir.listFiles(directoryFilter);
别人提到了:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
但是此处觉得是已定义了:
android.permission.READ_EXTERNAL_STORAGE
但是并没有搜索到
但是去VSCode中搜
android.permission.READ_EXTERNAL_STORAGE
有找到,不过都是 intermediate临时文件中的:
core/build/intermediates/bundle_manifest/debug/bundle-manifest/AndroidManifest.xml
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
有点点奇怪。
那去试试,记得之前是有
write的这个external storage
WRITE_EXTERNAL_STORAGE
的,然后去把之前的这些地方,也去加上这个read
core/AndroidManifest.xml
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
RI/AndroidManifest.xml
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
tools/provisioning/AndroidManifest.xml
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
确保都有了:
然后去重新编译,没问题。
然后重新调试看看,是否这个报错能消失。
结果问题依旧。
不是external storage的read的问题。
搜:
Perf getFolderSize Exception_1 java.lang.NullPointerException Attempt to get length of null array
Perf getFolderSize Exception_1 java.lang.NullPointerException
Issue with MediaRecorder. getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array | cna solution
How do i solve E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array? : androiddev
添加MultiDex后,我的android studio中出现运行时异常:“无法获取文件列表和NullPointerException” | 码农俱乐部 – Golang中国 – Go语言中文社区
说是添加了多个dex 才会出现此问题?
implementation 'com.android.support:multidex:1.0.3’
multiDexEnabled = true
搜搜项目中是否有:
multidex
multiDexEnabled
是有些地方有的
android – getting nullpointerexception for no specific reason – 漫漫字节|漫漫编程
这人遇到的问题很类似:
异常出现的位置 不固定。
app运行好像也没问题
加了READ_EXTERNAL_STORAGE和WRITE_EXTERNAL_STORAGE 没帮助
手机是 一加手机
但是安卓模拟器中没有此问题
我此处是小米9
此处去:
【未解决】Android Studio去红米Note8Pro中调试rcsjta的core的apk

转载请注明:在路上 » 【未解决】安卓项目rcsjta的core运行报错:Perf Fail to get file list com.gsma.rcs getFolderSize Exception_1 java.lang.NullPointerException: Attempt to get length of null array

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.178 seconds, using 23.35MB memory