Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用arouter-compiler:1.5.2, 编译时,报了一个泛型错误. #1017

Closed
exinglang opened this issue Jul 14, 2022 · 1 comment
Closed

使用arouter-compiler:1.5.2, 编译时,报了一个泛型错误. #1017

exinglang opened this issue Jul 14, 2022 · 1 comment

Comments

@exinglang
Copy link

编译时报错

:/Users/zcy/AndroidStudioProjects/WanMarket/app/build/tmp/kapt3/stubs/agentTestDebug/com/wan/wanmarket/bean/ListBean.java:84:** 错误: 无法从静态上下文中引用非静态 类型变量 T
public final com.wan.wanmarket.bean.ListBean[] newArray(int size) {}

编译文件

import java.lang.System;

@kotlinx.android.parcel.Parcelize()

public class ListBean implements android.os.Parcelable {
@org.jetbrains.annotations.Nullable()
private T data;
@org.jetbrains.annotations.Nullable()
private java.lang.String total;
@org.jetbrains.annotations.Nullable()
private java.lang.String page;
@org.jetbrains.annotations.Nullable()
private java.lang.String size;
public static final android.os.Parcelable.Creator<com.wan.wanmarket.bean.ListBean> CREATOR = null;

public ListBean() {
    super();
}

@org.jetbrains.annotations.Nullable()
public final T getData() {
    return null;
}

public final void setData(@org.jetbrains.annotations.Nullable()
T p0) {
}

@org.jetbrains.annotations.Nullable()
public final java.lang.String getTotal() {
    return null;
}

public final void setTotal(@org.jetbrains.annotations.Nullable()
java.lang.String p0) {
}

@org.jetbrains.annotations.Nullable()
public final java.lang.String getPage() {
    return null;
}

public final void setPage(@org.jetbrains.annotations.Nullable()
java.lang.String p0) {
}

@org.jetbrains.annotations.Nullable()
public final java.lang.String getSize() {
    return null;
}

public final void setSize(@org.jetbrains.annotations.Nullable()
java.lang.String p0) {
}

@java.lang.Override()
public int describeContents() {
    return 0;
}

@java.lang.Override()
public void writeToParcel(@org.jetbrains.annotations.NotNull()
android.os.Parcel parcel, int flags) {
}

@kotlin.Metadata(mv = {1, 6, 0}, k = 3)
public static final class Creator implements android.os.Parcelable.Creator<com.wan.wanmarket.bean.ListBean> {
    
    public Creator() {
        super();
    }
    
    @org.jetbrains.annotations.NotNull()
    @java.lang.Override()
    public final com.wan.wanmarket.bean.ListBean<T> createFromParcel(@org.jetbrains.annotations.NotNull()
    android.os.Parcel in) {
        return null;
    }
    
    @org.jetbrains.annotations.NotNull()
    @java.lang.Override()
    public final com.wan.wanmarket.bean.ListBean<T>[] newArray(int size) {
        return null;
    }
}

}

编译文件中这一行报错

@org.jetbrains.annotations.NotNull()
@java.lang.Override()
public final com.wan.wanmarket.bean.ListBean[] newArray(int size) {
return null;
}

kotlin源文件

@parcelize
open class ListBean: Parcelable {
var data: T? = null
var total: String? = null
var page: String? = null
var size: String? = null
}

不知如何解决,求教

@exinglang
Copy link
Author

解决了. 不使用@parcelize标注.
自行实现CREATOR即可

` companion object CREATOR : Parcelable.Creator<BaseResponse> {
override fun createFromParcel(parcel: Parcel): BaseResponse {
return BaseResponse(parcel)
}

    override fun newArray(size: Int): Array<BaseResponse<Parcelable>?> {
        return arrayOfNulls(size)
    }
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant