我試圖下載一個由php頁面輸出的Android APK文件。 下載成功,但嘗試安裝apk文件時發生解析包問題。 其實,直接訪問文件路徑(/var/www/xxx/HelloWorldTest.apk),這個方法完全安裝。(沒問題。) 但是我想使用通過php源碼的方法。在php下載Android二進制文件(apk),安裝apk文件時解析錯誤包
我有我的服務器上的Android應用程序,也有PHP代碼,如:
<?php
$path = "/var/www/xxx/";
$filename="HelloWorldTest.apk";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.android.package-archive");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($path . $filename));
readfile($path . $filename);
?>
有無HelloWorldTest(Android應用程序)清單一樣:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworldtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.helloworldtest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的設置: CentOS版本6.3(決賽),2.6.32-279.5.2.el6.x86_64,PHP 5.3.17 Android表版本:3.2.1內核版本:2.6.36.3
有b使用直接訪問方法並使用php方法結果進行inary dump。通過PHP
直接訪問(成功)
50 4B 03 04 14 00 08 08 08 00 F5 91 76 42 00 00
00 00 00 00 00 00 00 00 00 00 1C 00 04 00 72 65
73 2F 6C 61 79 6F 75 74 2F 61 63 74 69 76 69 74
79 5F 6D 61 69 6E 2E 78 6D 6C FE CA 00 00 6D 91
...
(安裝失敗)
0A 0A 50 4B 03 04 14 00 08 08 08 00 F5 91 76 42
00 00 00 00 00 00 00 00 00 00 00 00 1C 00 04 00
72 65 73 2F 6C 61 79 6F 75 74 2F 61 63 74 69 76
69 74 79 5F 6D 61 69 6E 2E 78 6D 6C FE CA 00 00
.....
這個問題似乎初始部分[0A 0A]在二進制碼中的溶液。