1

设想

我正在尝试创建我的第一个 android 库,它是 Volley 的扩展并提供用于Django REST Framework APIs集成的类。没有视图,只有 Java 类。

这是我的依赖项在模块中的样子:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.volley:volley:1.1.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

在模块应用程序中构建 gradle 时我没有收到任何错误。

当我执行 gradle task:clean install时,出现以下错误

错误

12:12:38 PM: Executing tasks 'clean install'...

Executing tasks: [clean, install]

:package-name:clean
:package-name:preBuild UP-TO-DATE
:package-name:preReleaseBuild UP-TO-DATE
:package-name:compileReleaseAidl NO-SOURCE
:package-name:compileReleaseRenderscript
:package-name:checkReleaseManifest
:package-name:generateReleaseBuildConfig
:package-name:generateReleaseResValues
:package-name:generateReleaseResources
:package-name:packageReleaseResources
:package-name:processReleaseManifest
:package-name:generateReleaseRFile
:package-name:prepareLintJar UP-TO-DATE
:package-name:generateReleaseSources
:package-name:javaPreCompileRelease
:package-name:compileReleaseJavaWithJavac
:package-name:extractReleaseAnnotations
:package-name:mergeReleaseConsumerProguardFiles UP-TO-DATE
:package-name:mergeReleaseShaders
:package-name:compileReleaseShaders
:package-name:generateReleaseAssets
:package-name:packageReleaseAssets
:package-name:packageReleaseRenderscript NO-SOURCE
:package-name:processReleaseJavaRes NO-SOURCE
:package-name:transformResourcesWithMergeJavaResForRelease
:package-name:transformClassesAndResourcesWithSyncLibJarsForRelease
:package-name:compileReleaseNdk NO-SOURCE
:package-name:mergeReleaseJniLibFolders
:package-name:transformNativeLibsWithMergeJniLibsForRelease
:package-name:transformNativeLibsWithSyncJniLibsForRelease
:package-name:bundleReleaseAar
...src/main/java/.../DjangoErrorListener.java:19: error: package com.android.volley does not exist
import com.android.volley.AuthFailureError;
                         ^
...src/main/java/.../DjangoErrorListener.java:20: error: package com.android.volley does not exist
import com.android.volley.ClientError;
                         ^
...src/main/java/.../DjangoErrorListener.java:21: error: package com.android.volley does not exist
import com.android.volley.NetworkError;
                         ^
… MANY SIMILAR ERRORS …
                         ^
...src/main/java/.../DjangoErrorListener.java:32: error: package Response does not exist
public abstract class DjangoErrorListener implements Response.ErrorListener {
                                                             ^
...src/main/java/.../DjangoErrorListener.java:64: error: cannot find symbol
    public void onErrorResponse(VolleyError error) {
                                ^
  symbol:   class VolleyError
  location: class DjangoErrorListener
...src/main/java/.../DjangoBaseRequest.java:20: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
  symbol: class JsonRequest
...src/main/java/.../DjangoBaseRequest.java:68: error: package Response does not exist
                             Response.Listener<T> listener,
                                     ^
...src/main/java/.../DjangoBaseRequest.java:76: error: cannot find symbol
    abstract protected Response<T> parseNetworkResponse(NetworkResponse response);
                                                        ^
  symbol:   class NetworkResponse
  location: class DjangoBaseRequest<T>
  where T is a type-variable:
    T extends Object declared in class DjangoBaseRequest
...src/main/java/.../DjangoBaseRequest.java:76: error: cannot find symbol
    abstract protected Response<T> parseNetworkResponse(NetworkResponse response);
                       ^
  symbol:   class Response
  location: class DjangoBaseRequest<T>
  where T is a type-variable:
    T extends Object declared in class DjangoBaseRequest

...src/main/java/.../DjangoJSONArrayResponseRequest.java:21: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
...src/main/java/.../DjangoJSONArrayResponseRequest.java:23: error: package com.android.volley does not exist
import com.android.volley.NetworkResponse;
                         ^

...src/main/java/.../DjangoJSONArrayResponseRequest.java:27: error: package com.android.volley.toolbox does not exist
import com.android.volley.toolbox.JsonRequest;
                                 ^
...src/main/java/.../DjangoJSONArrayResponseRequest.java:61: error: package Response does not exist
                                          Response.Listener<JSONArray> listener,
                                                  ^
...src/main/java/.../DjangoJSONArrayResponseRequest.java:85: error: package Response does not exist
                                          Response.Listener<JSONArray> listener,
                                                  ^
...src/main/java/.../DjangoJSONArrayResponseRequest.java:104: error: cannot find symbol
    protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
                                                       ^
  symbol:   class NetworkResponse
  location: class DjangoJSONArrayResponseRequest
...src/main/java/.../DjangoJSONArrayResponseRequest.java:104: error: cannot find symbol
    protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
              ^

...src/main/java/.../DjangoJSONObjectRequest.java:23: error: package com.android.volley does not exist
import com.android.volley.NetworkResponse;
                         ^
...src/main/java/.../DjangoJSONObjectRequest.java:62: error: package Response does not exist
                                   Response.Listener<JSONObject> listener,
                                           ^

… MANY SIMILAR ERRORS …


...src/main/java/.../DjangoJSONObjectRequest.java:84: error: package Response does not exist
                                   Response.Listener<JSONObject> listener,
                                           ^
...src/main/java/.../DjangoJSONObjectRequest.java:103: error: cannot find symbol
    protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
                                                        ^
  symbol:   class NetworkResponse
  location: class DjangoJSONObjectRequest
...src/main/java/.../DjangoJSONObjectRequest.java:103: error: cannot find symbol
    protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
              ^
  symbol:   class Response
  location: class DjangoJSONObjectRequest
...src/main/java/.../DjangoBaseRequest.java:67: error: cannot find symbol
                             @Nullable String jsonRequest,
                              ^

… MANY SIMILAR ERRORS …

  symbol:   class Nullable
  location: class DjangoJSONObjectRequest
...src/main/java/.../DjangoJSONObjectRequest.java:85: error: cannot find symbol
                                   @Nullable DjangoErrorListener errorListener,
                                    ^
  symbol:   class Nullable
  location: class DjangoJSONObjectRequest
...src/main/java/.../DjangoBaseRequest.java:81: error: malformed HTML
     * @return Map<String, String> a Map of headers
                  ^
...src/main/java/.../DjangoBaseRequest.java:81: error: bad use of '>'
     * @return Map<String, String> a Map of headers
                                 ^
...src/main/java/.../DjangoBaseRequest.java:82: error: reference not found
     * @throws AuthFailureError from super
       ^
...src/main/java/.../DjangoBaseRequest.java:65: warning: no @param for context
    public DjangoBaseRequest(int method,
           ^
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
...src/main/java/.../DjangoErrorListener.java:62: error: reference not found
     * @param error A {@link VolleyError} object.
                             ^
...src/main/java/.../DjangoJSONArrayResponseRequest.java:46: error: reference not found
     * Based on {@link com.android.volley.toolbox.JsonObjectRequest}
                       ^
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
...src/main/java/.../DjangoJSONObjectRequest.java:47: error: reference not found
     * Based on {@link com.android.volley.toolbox.JsonObjectRequest}
                       ^
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
javadoc: warning - Class Nullable not found.
:package-name:javadoc
6 errors
62 warnings
:package-name:javadoc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':package-name:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '...build/tmp/javadoc/javadoc.options'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

        * Get more help at https://help.gradle.org

        BUILD FAILED in 1s
23 actionable tasks: 21 executed, 2 up-to-date
12:12:40 PM: Tasks execution finished 'clean install'.

源代码

GitHub

我一直在互联网上搜索,但没有成功!以前有人遇到过这个错误吗?我究竟做错了什么?

4

2 回答 2

1

问题出在Javadoc. javadoc 中存在非 ASCII 字符会导致该问题。要解决此问题,您应该使用以下代码段禁用它。当我查看您的项目源代码时,您应该将其添加到您的bintray_script文件中。

tasks.withType(Javadoc) {
    enabled = false
}
于 2018-12-27T18:03:22.913 回答
1

也许您在 Google 上搜索错误的关键字。如果您要修复javadoc而不是跳过它,这将有所帮助。我做了一些研究并找到了解决方案。

afterEvaluate {
    javadoc.classpath += files(android.libraryVariants.collect { variant ->
        variant.javaCompiler.classpath.files
    })
}

这是原始答案

我也在 GitHub 上推送了解决方案。

于 2018-12-29T18:07:32.627 回答