Android APK扩展文件expPath不存在

Android APK扩展文件expPath不存在,android,apk,Android,Apk,我一直在尝试将我的应用程序转换为使用APK扩展文件,由于某些原因,下面的代码找不到我的APK扩展文件的路径 static String[] getAPKExpansionFiles(Context ctx, int mainVersion, int patchVersion) { Log.v(TAG, "Utils.getAPKExpansionFiles [27] mainVersion is " + mainVersion + " patchVersion = " + patchVe

我一直在尝试将我的应用程序转换为使用APK扩展文件,由于某些原因,下面的代码找不到我的APK扩展文件的路径

static String[] getAPKExpansionFiles(Context ctx, int mainVersion, int patchVersion) {
    Log.v(TAG, "Utils.getAPKExpansionFiles [27] mainVersion is " + mainVersion + " patchVersion = " + patchVersion );
    String packageName = ctx.getPackageName();
    Log.v(TAG, "Utils.getAPKExpansionFiles [27] packageName is [" + packageName + "]" );
    Vector<String> ret = new Vector<String>();
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        Log.v(TAG, "Utils.getAPKExpansionFiles [32] MEDIA_MOUNTED" );
        // Build the full path to the app's expansion files
        File root = Environment.getExternalStorageDirectory();
        Log.v(TAG, "Utils.getAPKExpansionFiles [35] root = " + root);
        File expPath = new File(root.toString() + EXP_PATH + packageName);
        Log.v(TAG, "Utils.getAPKExpansionFiles [37] expPath " + expPath );

        // Check that expansion file path exists
        if (expPath.exists()) {
                ...
        } else {
            Log.v(TAG, "Utils.getAPKExpansionFiles [60] expPath DOES NOT EXISTS" );
        }
    } else {
        Log.v(TAG, "Utils.getAPKExpansionFiles [57] NOT MEDIA_MOUNTED" );
    }
    String[] retArray = new String[ret.size()];
    ret.toArray(retArray);
    return retArray;
}
。。。即使路径确实存在且文件存在,如本屏幕截图所示:

我很确定我没有打字错误,而且路径是存在的。那么为什么
expPath.exists()
会返回false呢

谢谢你的回答,泰德。。。但我还是在日志中找到了这个

03-20 21:59:48.198: V/GospelofMatthewAudiobook(11988): Utils.getAPKExpansionFiles [37] expPath /mnt/sdcard/Android/obb/com.redcricket.GospelofMatthewAudiobook/main.1.com.redcricket.GospelofMatthewAudiobook.obb
03-20 21:59:48.198: V/GospelofMatthewAudiobook(11988): Utils.getAPKExpansionFiles [60] expPath DOES NOT EXISTS

。。。可能是我用Windows创建了目录,而不是
avd
。要创建目录并将APK扩展zip文件推送到我的手机上,
adb
命令是什么?

您需要命名文件本身。与此相反:

File expPath = new File(root.toString() + EXP_PATH + packageName);
使用以下命令:

File expPathDir = new File(root.toString() + EXP_PATH + packageName);
File expPath = new File(expPathDir,
    String.format("main.%d.%s.obb", mainVersion, packageName));
这将适用于主扩展包。您应该有一个类似的方法来访问使用格式
String.format(“patch.%d.%s.obb”、patchVersion、packageName)”的修补程序。

文件的完整路径应该类似于

/mnt/sdcard/Android/obb/com.redcricket.GospelofMatthewAudiobook/main.123./mnt/sdcard/Android/obb/com.redcricket.GospelofMatthewAudiobook.obb

我在
C:\Users\dogface\AppData\Local\Android\Android sdk\platform tools>中找到了
adb.exe
,我尝试了这个命令:
C:\Users\dogface\AppData\Local\Android\Android sdk\platform tools>adb.exe推送C:\main.1.com.redcricket.gospelofmattheaudiobook.obb/mnt/sdcard/Android/obb/com.redcricket.gospelofmatthewadiobook\main.1.com.redcricket.gospelofmatthewadiob ook.obb未能将“c:\main.1.com.redcricket.redcricket.gospelofmatthewadiobook.obb”复制到“/mnt/sdcard/Android/obb/com.redcricket.gospelofmatthewadiobook\main.1.com.redcricket.gospelofmatthewadiobook.obb”:权限被拒绝C:\Users\dogface\AppData\Local\Android\Android sdk\platform tools>
难道%i不应该是%d吗?您的答案也可以应用于我的答案吗?但它不起作用@java-是的,
%i
应该是
%d
。谢谢你的帮助。我来看看你的另一个问题。如果你能抽出时间,我将非常高兴:-)
/mnt/sdcard/Android/obb/com.redcricket.GospelofMatthewAudiobook/main.123./mnt/sdcard/Android/obb/com.redcricket.GospelofMatthewAudiobook.obb