为sam.mypac.BDBAPI导入D:\ Work \ app \ src \ main \ aidl \ sam \ mypac \ BDBAPI.aidl时出错

问题描述

当我尝试重建项目时,我得到:

> Task :app:compileDebugAidl Failed
error while importing D:\Work\app\src\main\aidl\sam\mypac\BDBAPI.aidl for sam.mypac.BDBAPI

Process 'command 'C:\Users\rente\AppData\Local\Android\Sdk\build-tools\29.0.2\aidl.exe'' finished with non-zero exit value 1

BDBAPI.aidl:

package sam.mypac;

parcelable ExRow;

interface BDBAPI {
    List<ExRow> get_rows (String cname,int si);
}

DBAIDL.aidl:

package sam.mypac;

import sam.mypac.BDBAPI;

parcelable ExRow;

interface DBAIDL {
    List<ExRow> get_exrows (String cname,int si);
    void registerCallback (BDBAPI dbapi);
}

ExRow.java:

package sam.mypac;

import android.os.Parcel;
import android.os.Parcelable;

public class ExRow implements Parcelable {
    int si;
    String title;

    public static final Parcelable.Creator<ExRow> CREATOR = new Parcelable.Creator<ExRow>() {
        public ExRow createFromParcel (Parcel source) {
            return new ExRow (source);
        }

        public ExRow[] newArray (int size) {
            return new ExRow[size];
        }
    };

    ExRow (Integer si,String title) {
        this.si = si;
        this.title = title;
    }

    ExRow (Parcel parcel) {
        this.si = parcel.readInt();
        this.title = parcel.readString();
    }

    public int describeContents() {
        return 0;
    }

    public String get_cmpr() {
        return get_title();
    }

    public int get_si() {
        return this.si;
    }

    public String get_title() {
        return this.title;
    }

    public void writetoParcel (Parcel dst,int flags) {
        dst.writeInt (get_si());
        dst.writeString (get_title());
    }
}

DBService.java:

package sam.mypac;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.os.remoteexception;
import android.support.annotation.Nullable;

import java.util.List;

public class DBService extends Service {
    public final RemoteCallbackList<BDBAPI> dbapis = new RemoteCallbackList<>();

    private final DBAIDL.Stub mBinder = new DBAIDL.Stub() {
        public List<ExRow> get_exrows (String cname,int si) throws remoteexception {
            List<ExRow> exrows = null; // dbapi.get_rows (cname,si);
            return exrows;
        }

        public void registerCallback (BDBAPI dbapi) {
            if (dbapi != null) dbapis.register (dbapi);
        }
    };

    @Nullable
    @Override
    public IBinder onBind (Intent intent) {
        return mBinder;
    }

    @Override
    public int onStartCommand (Intent intent,int flags,int startId) {
        return super.onStartCommand (intent,flags,startId);
    }
}

MyActivity.java:

package sam.mypac;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

public class MyActivity extends AppCompatActivity {
    ServiceConnection dbServiceConnection = new ServiceConnection() {
        public void onServiceConnected (ComponentName name,IBinder ib_service) {
            dbService = DBAIDL.Stub.asInterface (ib_service);
        }

        public void onServicedisconnected (ComponentName name) {
            dbService = null;
        }
    };

    private final BDBAPI.Stub dbapi = new BDBAPI.Stub() {
        @Override
        public List<ExRow> get_rows (String cname,int si) {
            return null; //Temporary stub
        }
    };

    private int mode;
    private Integer si_vendor;
    private int company_type;
    private DBAIDL dbService;
    private SimpleDateFormat frmt_full = new SimpleDateFormat ("yyyyMMdd",Locale.US);

    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity_bean);
    }
/*
.... other code commented
*/
}

但是,当我将这些文件放在单独的项目中并尝试单独构建时,一切都很好! 很奇怪,但是如果不在这文件中,该在哪里搜索错误或配置错误

当我在BDBAPI.aidl中注释行时:

//parcelable ExRow;
....
//List<ExRow> get_rows (String cname,int si);

那一切也都顺利通过了!

有人知道在其他地方查找吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...