2013-03-05 3 views
2

현재 앱에 APK 확장 기능을 추가하려고 할 때 그 성가신 컴파일 오류가 발생했습니다. "XAPK 파일을 유형으로 확인할 수 없습니다".XAPK 파일을 유형으로 해결할 수 없습니다.

This은 내 프로젝트에 APK 확장 파일을 추가하는 데 사용한 가이드입니다. 내가 Google을 통해, 장소를 찾을 때까지

+0

거기에 질문이 있습니까? –

+0

아니요, 같은 실수로 사람들이 길을 잃지 않도록하기 위해 자필 답변했습니다. 나는 그것이 유용 할 수 있다고 생각했다. –

+0

그런 다음 질문과 별도 답변으로 나누십시오. –

답변

1

나는 누군가가 정의한 몇 시간을 사용했습니다이 :

private static class XAPKFile { 
     public final boolean mIsMain; 
     public final int mFileVersion; 
     public final long mFileSize; 

     XAPKFile(boolean isMain, int fileVersion, long fileSize) { 
      mIsMain = isMain; 
      mFileVersion = fileVersion; 
      mFileSize = fileSize; 
     } 
} 

그래서, 당신이 얻을 경우, 확인해야 할 유일한 것은 이 클래스를 정의한 경우에도 동일한 오류가 발생합니다. Android에서는 제공하지 않습니다. 아마도 FileSize를 코드에 넣고 싶지 않거나 실수가 있기 때문일 수 있습니다.

0

엑스트라 프로젝트의 SampleDownloaderActivity에서이 클래스를 찾을 수 있습니다. 여기에는 APK 확장 파일 구현에 대한 유용한 예제가 포함되어 있습니다. 당신이 구글이 확장 라이브러리 (through the SDK Manager)를 재생 다운로드 한 경우, 당신은 아래에서 찾을 수 있습니다 :

YourPathToAndroidSdk/엑스트라/여기/play_apk_expansion/downloader_library의 편의를 위해

, 내가 붙여 복사 한이 클래스를 구글 XAPK 파일 xAPKS 배열 (확장 라이브러리의 v3에 있음) :

/** 
* This is a little helper class that demonstrates simple testing of an 
* Expansion APK file delivered by Market. You may not wish to hard-code 
* things such as file lengths into your executable... and you may wish to 
* turn this code off during application development. 
*/ 

private static class XAPKFile { 
    public final boolean mIsMain; 
    public final int mFileVersion; 
    public final long mFileSize; 

    XAPKFile(boolean isMain, int fileVersion, long fileSize) { 
     mIsMain = isMain; 
     mFileVersion = fileVersion; 
     mFileSize = fileSize; 
    } 
} 

/** 
* Here is where you place the data that the validator will use to determine 
* if the file was delivered correctly. This is encoded in the source code 
* so the application can easily determine whether the file has been 
* properly delivered without having to talk to the server. If the 
* application is using LVL for licensing, it may make sense to eliminate 
* these checks and to just rely on the server. 
*/ 
private static final XAPKFile[] xAPKS = { 
     new XAPKFile(
       true, // true signifies a main file 
       3, // the version of the APK that the file was uploaded 
        // against 
       687801613L // the length of the file in bytes 
     ), 
     new XAPKFile(
       false, // false signifies a patch file 
       4, // the version of the APK that the patch file was uploaded 
        // against 
       512860L // the length of the patch file in bytes 
     )    
}; 
관련 문제