Android Expansion Files - resource not found when testing

前端 未结 2 1328
北恋
北恋 2021-01-17 04:07

This is my package name: com.abc.ss

Now i have manually created a folder with package name com.abc.s in mnt/sdcard/Android/obb/com.abc.ss/main.2.com.abc.ss.obb

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 04:12

    looks like Condition failed to find your file in sdcard

     boolean expansionFilesDelivered() {
        for (XAPKFile xf : xAPKS) {
            String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsBase, xf.mFileVersion);
            if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false))
                return false;
        }
        return true;
    }
    

    have put the fake file in exact directory?

    private final static String EXP_PATH = "/Android/obb/";
    
    static String[] getAPKExpansionFiles(Context ctx, int mainVersion, int patchVersion) {
        String packageName = ctx.getPackageName();
        Vector ret = new Vector();
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            // Build the full path to the app's expansion files
            File root = Environment.getExternalStorageDirectory();
            File expPath = new File(root.toString() + EXP_PATH + packageName);
    
            // Check that expansion file path exists
            if (expPath.exists()) {
                if ( mainVersion > 0 ) {
                    String strMainPath = expPath + File.separator + "main." +
                            mainVersion + "." + packageName + ".obb";
                    File main = new File(strMainPath);
                    if ( main.isFile() ) {
                            ret.add(strMainPath);
                    }
                }
                if ( patchVersion > 0 ) {
                    String strPatchPath = expPath + File.separator + "patch." +
                            mainVersion + "." + packageName + ".obb";
                    File main = new File(strPatchPath);
                    if ( main.isFile() ) {
                            ret.add(strPatchPath);
                    }
                }
            }
        }
        String[] retArray = new String[ret.size()];
        ret.toArray(retArray);
        return retArray;
    } 
    

    you should push the (obb fake file) file in here (com.your.packagename) enter image description here with your package name (package name should ve created programatically)

        String xapkFilePath = getAPKExpansionFiles(SampleDownloaderActivity.this);
                    Log.d("CopyFromAPKEXP", "OBBFileName: " + xapkFilePath);
                    String exportDirectory = Environment
                            .getExternalStorageDirectory().getAbsolutePath()
                            + "/Android/data/"
                            + SampleDownloaderActivity.this.getPackageName()
                            + "/files/";
                    File exportDirectoryFilepath = new File(exportDirectory);
    
                    exportDirectoryFilepath.mkdirs();
    

提交回复
热议问题