gpt4 book ai didi

Android 扩展文件 - 找不到资源

转载 作者:太空狗 更新时间:2023-10-29 15:14:31 28 4
gpt4 key购买 nike

我正在尝试让我的应用下载一个扩展文件。这是我的主要内容:

package tm.down.rob;

import com.google.android.vending.expansion.downloader.DownloadProgressInfo;
import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
import com.google.android.vending.expansion.downloader.Helpers;
import com.google.android.vending.expansion.downloader.IDownloaderClient;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.os.Messenger;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;

public class main extends Activity implements IDownloaderClient {
/** Called when the activity is first created. */

TextView tv1;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

//////////
tv1 = (TextView)findViewById(R.id.textView1);
//////////

// Check whether the file have been downloaded.
String mainFileName = Helpers.getExpansionAPKFileName(this, true, 1);
boolean fileExists = Helpers.doesFileExist(this, mainFileName, 32921796L, false);

if (!fileExists) {
Intent launcher = getIntent();
Intent fromNotification = new Intent(this, getClass());
fromNotification.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
fromNotification.setAction(launcher.getAction());

if (launcher.getCategories() != null) {
for (String cat : launcher.getCategories()) {
fromNotification.addCategory(cat);
}
}

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, fromNotification, PendingIntent.FLAG_UPDATE_CURRENT);

try {

int result = DownloaderClientMarshaller.startDownloadServiceIfRequired( this, pendingIntent, ExpansionFileDownloaderService.class);
if (DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED != result) {

// implement Downloading UI.
tv1.setText("Need to download.");

return;
}

} catch (Exception e) {
Log.e("apk-expansion-files", "NameNotFoundException occurred. " + e.getMessage(), e);
}
}

tv1.setText("Downloaded!");

}


///////////////////////////////////////////////////


@Override
public void onServiceConnected(Messenger m) {
tv1.setText("onServiceConnected: " + m.toString() );
}

///////////

@Override
public void onDownloadStateChanged(int newState) {
tv1.setText("onDownloadStateChanged: " + String.valueOf(newState) );
}

////////////

@Override
public void onDownloadProgress(DownloadProgressInfo progress) {
ProgressBar mPB = (ProgressBar)findViewById(R.id.progressBar1);

progress.mOverallTotal = progress.mOverallTotal;
mPB.setMax((int) (progress.mOverallTotal >> 8));
mPB.setProgress((int) (progress.mOverallProgress >> 8));
//mProgressPercent.setText(Long.toString(progress.mOverallProgress * 100 / progress.mOverallTotal) + "%");
//mProgressFraction.setText(Helpers.getDownloadProgressString(progress.mOverallProgress,progress.mOverallTotal));

}

////////////




}

我编译了 apk 并使用重命名为 ma​​in.1.tm.down.rob.obb 的 zip 文件将其上传到 marker 但是,当我运行我的应用程序时,它仍然抛出我“下载失败,因为找不到资源”...

有什么想法吗?谢谢!

最佳答案

当我尝试使用部署到我的 Maven 存储库的下载程序库 apklib+jar 时,我遇到了同样的问题 https://github.com/mosabua/maven-android-sdk-deployer

当我使用这个 Gradle 构建脚本将下载器库重新部署到我的 Maven 存储库时:

buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}

apply plugin: 'android-library'
apply plugin: 'maven'

repositories {
maven {
url "http://repository_url/nexus/content/repositories/release"
}
maven {
url "http://repository_url/nexus/content/repositories/release/"
}
mavenCentral()
}

dependencies {
compile 'com.google.android.licensing:play-licensing:2.+@aar'
}

android {
compileSdkVersion 19
buildToolsVersion '19.1'

sourceSets {
main {
assets.srcDirs = ['assets']
res.srcDirs = ['res']
aidl.srcDirs = ['src']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
java.srcDirs = ['src']
manifest.srcFile 'AndroidManifest.xml'
}
}
}

uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://repository_url/nexus/content/repositories/release/") {
authentication(userName: "user", password: "password")
}

pom.version = "3.0.0"
pom.artifactId = "play-apk-expansion-downloader"
pom.groupId = "com.google.android.apk.expansion"
}
}
}

并更改了对 AAR 包的依赖:

dependencies {
compile 'com.google.android.apk.expansion:play-apk-expansion-downloader:3.+@aar'
}

它开始起作用了。

关于Android 扩展文件 - 找不到资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13805129/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com