gpt4 book ai didi

java.lang.NoClassDefFoundError : Failed resolution of: Landroid/webkit/PacProcessor

转载 作者:行者123 更新时间:2023-12-04 23:40:39 34 4
gpt4 key购买 nike

真的找不到词,我的项目只是不从一天编译到另一天。
这就是我所做的:
我下载并显示一个 PDF,然后我将其作为保存的 PDF 打印到设备上,然后崩溃发生了。
这是崩溃:

at java.lang.Class java.lang.Class.classForName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:-2)
at java.lang.Class java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:453)
at java.lang.Class android.webkit.WebViewFactory.getWebViewProviderClass(java.lang.ClassLoader) (WebViewFactory.java:176)
at java.lang.Class android.webkit.WebViewFactory.getProviderClass() (WebViewFactory.java:459)
at android.webkit.WebViewFactoryProvider android.webkit.WebViewFactory.getProvider() (WebViewFactory.java:251)
at android.webkit.WebViewFactoryProvider android.webkit.WebView.getFactory() (WebView.java:2681)
at void android.webkit.WebView.ensureProviderCreated() (WebView.java:2676)
at void android.webkit.WebView.setOverScrollMode(int) (WebView.java:2741)
at void android.view.View.<init>(android.content.Context) (View.java:4815)
at void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int) (View.java:4956)
at void android.view.ViewGroup.<init>(android.content.Context, android.util.AttributeSet, int, int) (ViewGroup.java:659)
at void android.widget.AbsoluteLayout.<init>(android.content.Context, android.util.AttributeSet, int, int) (AbsoluteLayout.java:55)
at void android.webkit.WebView.<init>(android.content.Context, android.util.AttributeSet, int, int, java.util.Map, boolean) (WebView.java:659)
at void android.webkit.WebView.<init>(android.content.Context, android.util.AttributeSet, int, int) (WebView.java:604)
at void android.webkit.WebView.<init>(android.content.Context, android.util.AttributeSet, int) (WebView.java:587)
at void android.webkit.WebView.<init>(android.content.Context, android.util.AttributeSet) (WebView.java:574)
at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:343)
at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
at android.view.View com.android.internal.policy.PhoneLayoutInflater.onCreateView(java.lang.String, android.util.AttributeSet) (PhoneLayoutInflater.java:58)
at android.view.View android.view.LayoutInflater.onCreateView(android.view.View, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:720)
at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:788)

(实际的错误太长了,我无法在stackoverflow中发布,而且都不是我自己的代码,它与Android的webview有问题。)

这是发生崩溃的 Activity 代码:
public class ActivityPrintSurvey extends ActivityBase implements MVPView, View.OnClickListener, SendScannedSignedDocumentTask.SendScannedSignedDocumentCallback {

Document document;
Patient patient;
SurveyBundle surveyBundle;

View hider;
Button printBtn;
Button backBtn;
WebView webView;
ProgressBar progressBar;
Switch switcher;

boolean canPrint = false;

PrintManager printManager;
String jobName;

String fileName;

String pdfUrl;
String showPdfUrl;
private int SIGNING_DONE_1 = 105;

int runnableCounter = 0;
final int RUNNABLE_MAX = 3;

private void log(Object o) {

Log.i("PRINTING_ACT", o.toString());
}


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_print_survey);


log("activity started");

hider = findViewById(R.id.hider);
printBtn = findViewById(R.id.print_btn);
backBtn = findViewById(R.id.back_btn);
webView = findViewById(R.id.web_view);
progressBar = findViewById(R.id.progressbar);
switcher = findViewById(R.id.read_and_accepted_switch);


document = (Document) getIntent().getSerializableExtra("document");
patient = (Patient) getIntent().getSerializableExtra("patient");
surveyBundle = (SurveyBundle) getIntent().getSerializableExtra("survey_bundle");

jobName = this.getString(R.string.app_name) + " Document";
printManager = (PrintManager) this.getSystemService(Context.PRINT_SERVICE);

printBtn.setOnClickListener(this);
backBtn.setOnClickListener(this);


showPDF();
}


private void showPDF() {

log("starting to show pdf");

pdfUrl = document.getPdfUrl();

String embedUrl = "https://docs.google.com/gview?embedded=true&url=";
showPdfUrl = embedUrl + pdfUrl;

progressBar.setVisibility(View.VISIBLE);
hider.setVisibility(View.VISIBLE);

final Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {

if (runnableCounter < RUNNABLE_MAX) {
runnableCounter++;
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(showPdfUrl);
handler.postDelayed(this, 1000);
//Szörnyűséges a helyzet, az android szemét használhatatlan webview nem mindig jeleníti meg a pdf-et, ezért rá kell frissíteni párszor, hogy biztos megjelenítse, ez van.
} else {
progressBar.setVisibility(View.GONE);
hider.setVisibility(View.GONE);

}
}
};
handler.post(runnable);
downloadPDF();
}


public void downloadPDF() {

log("starting to download pdf");

fileName = FileHelper.generateTempFileName();

ANRequest.DownloadBuilder downloadBuilder = AndroidNetworking.download(pdfUrl, FileHelper.getTempFileDirectory(this), fileName);
downloadBuilder.doNotCacheResponse();
ANRequest request = downloadBuilder.build();

request.setDownloadProgressListener(new DownloadProgressListener() {
@Override
public void onProgress(long bytesDownloaded, long totalBytes) {
// do anything with progress
Log.i("ON_PROGRESS", bytesDownloaded + " / " + totalBytes);

}
}).startDownload(new DownloadListener() {
@Override
public void onDownloadComplete() {
// do anything after completion
canPrint = true;
}

@Override
public void onError(ANError error) {
// handle error
Toast.makeText(ActivityPrintSurvey.this, error.getMessage(), Toast.LENGTH_LONG).show();
}
});

}

public void print() {

log("starting to print");

printManager.print(jobName, new PrintDocumentAdapter() {


@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) {
InputStream input = null;
OutputStream output = null;

log("onWrite() called for printing");

try {

File file = FileHelper.readTempFile(ActivityPrintSurvey.this, fileName);

input = new FileInputStream(file);
output = new FileOutputStream(destination.getFileDescriptor());

byte[] buf = new byte[1024];
int bytesRead;

while ((bytesRead = input.read(buf)) > 0) {
output.write(buf, 0, bytesRead);
}

callback.onWriteFinished(new PageRange[]{PageRange.ALL_PAGES});
log("onWriteFinished() called for printing");

} catch (Exception e) {
//Catch exception
e.printStackTrace();
log("Exception 1: " + e.getMessage());
} finally {
try {
input.close();
output.close();
} catch (IOException e) {
e.printStackTrace();
log("Exception 2: " + e.getMessage());
}
}
}

@Override
public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) {
log("onLayout() done");

if (cancellationSignal.isCanceled()) {
callback.onLayoutCancelled();
log("onLayoutCancelled()");
return;
}

PrintDocumentInfo pdi = new PrintDocumentInfo.Builder(fileName/*Ez itt lehet bármi, kiskutya füle, nem kell megegyeznie az alap file nevvel*/).setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT).build();
callback.onLayoutFinished(pdi, true);
log("onLayoutFinished() called");
}

@Override
public void onFinish() {

FileHelper.deleteTempFiles(ActivityPrintSurvey.this);

log("onFinish() done");

// ha kész a nyomtatás, jöhet a valós aláírás tollal, majd visszafotózás, és feltöltés

new AlertDialog.Builder(ActivityPrintSurvey.this)
.setTitle(getString(R.string.next_step))
.setMessage(getString(R.string.please_scan_the_printed_and_signed_document))
.setPositiveButton(getString(R.string.scan), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
startScanningByCameraPhoto();
}
})
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {

}
})
.show();

log("showing alert dialog");

}
}, null);
}

public void startScanningByCameraPhoto() {

// start picker to get image for cropping and then use the image in cropping activity
CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.start(this);

log("startScanningByCameraPhoto");
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

log("onActivityResult called");

if (resultCode == Activity.RESULT_OK) {
if (requestCode == SIGNING_DONE_1) {

log("RESULT_OK from SIGNING_DONE_1 -> calling .finish()");

Intent intent = new Intent();
intent.putExtra("document", document);
setResult(Activity.RESULT_OK, intent);
finish();
}
} else {
log("1. Error: resultCode NOT RESULT OK");
}

if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {

log("RESULT_OK from CROP_IMAGE_ACTIVITY_REQUEST_CODE");

Uri resultUri = result.getUri();

File file = new File(resultUri.getPath());

showLoading();

SendScannedSignedDocumentTask task = new SendScannedSignedDocumentTask(this, this, DatabaseHelper.getInstance().readLoggedInUser().getUserToken(), document, patient, file);
task.execute();

} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
log("2. Error: resultCode NOT RESULT OK: " + error.getMessage());
error.printStackTrace();
}
}

}


@Override
public void handleUploadScannedDocumentAPIDone(String error) {

hideLoading();

if (error != null) {
log("handleUploadScannedDocumentAPIDone, error:" + error);
DialogHelper.showInfo(this, error);
} else {
log("handleUploadScannedDocumentAPIDone -> finishing()");
setResult(Activity.RESULT_OK);
Toast.makeText(this, "✔ " + getString(R.string.uploaded), Toast.LENGTH_LONG).show();
finish();
}
}

@Override
public void onClick(View v) {

if (v.equals(printBtn)) {

if (switcher.isChecked()) {
if (canPrint) {
print();
} else {
Toast.makeText(this, "PDF not found in device. Retrying download...", Toast.LENGTH_LONG).show();
downloadPDF();
}
} else {
DialogHelper.showInfo(this, getString(R.string.please_check_the_checkbox));
}

} else if (v.equals(backBtn)) {
onBackPressed();
}
}

public void hideLoading() {
progressBar.setVisibility(View.GONE);
}

@Override
public void showLoading() {
progressBar.setVisibility(View.VISIBLE);
}

@Override
public void showError(String error, String code) {
hideLoading();
canPrint = false;
DialogHelper.showError(this, error);
log("showing error: " + error);
}


@Override
public void showSuccess(Object... object) {

hideLoading();

String api = object[0].toString();

if (api.equals("eject_patient")) {

log("showSuccess: " + "finishing activity.");

Intent intent = new Intent(this, ActivityWaitingForPatient.class);
startActivity(intent);
finish();

} else {
log("showSuccess: " + "ERROR: " + api + " not equals " + "eject_patient");
}
}


@Override
public void onResume() {
super.onResume();
LayoutTextSizeChanger.changeAllTextSizeInLayout((ViewGroup) findViewById(R.id.main_cont), FontUtil.loadFontSize(this));

log("onResume()" );
}


}

最佳答案

嗯...引用类加载器问题的间歇性问题。 + 一个巨大的堆栈跟踪。
您提供的少量证据可能指向无声的 IO 类型错误。
例如,您正在使用的 android 在运行时动态加载类,并且由于某种原因,它尝试使用的任何 jar 的主机文件夹还包含该 pdf 文件,该文件主动写入/读取...或出于任何原因,整个文件系统分区被标记为锁定。
在这种情况下,您会遇到间歇性的类加载器错误,就像您引用的错误一样。
还有这个:

try {
input.close(); <--- if exception occurs at this point, output will never close.
output.close();
} catch (IOException e) {
e.printStackTrace();
log("Exception 2: " + e.getMessage());
}
......我不知道......老实说,几乎没有什么信息可以引用。例如,您没有发布 finish() 的内容例程,并且该堆栈跟踪不包含对您的代码的引用(至少我可以看到)......所以这是一种在黑暗中的狂野刺伤。

关于java.lang.NoClassDefFoundError : Failed resolution of: Landroid/webkit/PacProcessor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70756680/

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