gpt4 book ai didi

java - JGit 错误-> 由 : java. 引起 lang.NoSuchMethodError: No virtual method toPath()

转载 作者:搜寻专家 更新时间:2023-11-01 02:23:20 27 4
gpt4 key购买 nike

我正在尝试在 Android Java 上克隆存储库,但在调用方法 toPath() 时出现错误。显然 File 对象没有 toPath() 方法。

public void gitClone() throws GitAPIException {

// File dir = new File(_ctx.getExternalFilesDir(null) + File.separator + "openshift_files");
Bundle b2 = getIntent().getExtras();
//File localPath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
final File localPath = new File(getExternalFilesDir(null) + File.separator + getCurrentApp().getName());

Git.cloneRepository()
.setURI(getUrlGit())
.setDirectory(localPath)
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(b2.getString("OPEN_SHIFT_USER"), b2.getString("OPEN_SHIFT_PASSWORD")))
.call();
System.out.println("Success!");
}

这是堆栈跟踪

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
E/AndroidRuntime: Process: com.javier.openshift, PID: 22919
E/AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:304)
E/AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
E/AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:242)
E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime: Caused by: java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-libart.jar)
E/AndroidRuntime: at org.eclipse.jgit.util.FileUtil.exists(FileUtil.java:149)
E/AndroidRuntime: at org.eclipse.jgit.util.FS_POSIX.exists(FS_POSIX.java:275)
E/AndroidRuntime: at org.eclipse.jgit.internal.storage.file.ObjectDirectory.exists(ObjectDirectory.java:193)
E/AndroidRuntime: at org.eclipse.jgit.internal.storage.file.FileRepository.<init>(FileRepository.java:207)
E/AndroidRuntime: at org.eclipse.jgit.lib.BaseRepositoryBuilder.build(BaseRepositoryBuilder.java:579)
E/AndroidRuntime: at org.eclipse.jgit.api.InitCommand.call(InitCommand.java:113)
E/AndroidRuntime: at org.eclipse.jgit.api.CloneCommand.init(CloneCommand.java:161)
E/AndroidRuntime: at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:132)
E/AndroidRuntime: at com.javier.apps.AppsActivity.gitClone(AppsActivity.java:981)
E/AndroidRuntime: at com.javier.apps.AppsActivity$AsyncTaskCloneRepository.doInBackground(AppsActivity.java:1002)
E/AndroidRuntime: at com.javier.apps.AppsActivity$AsyncTaskCloneRepository.doInBackground(AppsActivity.java:985)
E/AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:292)
E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818) 

最佳答案

您使用的 JGit 版本太新了。从 JGit 4.0.0 开始,最低 Java 版本从 Java 5 提高到 Java 7 ( see Eclipse documentation here )。 JGit 使用 Java 7 Path API,它不适用于您正在使用的 JDK。

您应该降级到 JGit 3.7.1(这是 3.x 系列的最新版本)。

关于java - JGit 错误-> 由 : java. 引起 lang.NoSuchMethodError: No virtual method toPath(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32873216/

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