Android Studio:无法生成签名 APK

Android Studio: Unable to Generate Signed APK

尝试使用 Android Studio 生成已签名的 apk 时,出现以下错误:

Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.tokom.globol.CustomGrid) [Instantiatable]

我试图通过在 class 中使用 super 来解决这个问题,但它显示红线错误。

这里是CustomGrid.java

package com.tokom.globol;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class CustomGrid extends BaseAdapter{
    private Context mContext;
    private final String[] web;
    private final int[] Imageid;
    public CustomGrid(Context c,String[] web,int[] Imageid ) {
        mContext = c;
        this.Imageid = Imageid;
        this.web = web;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return web.length;
    }
    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        View grid;
        LayoutInflater inflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null) {
            grid = new View(mContext);
            grid = inflater.inflate(R.layout.grid_single, null);

        } else {
            grid = convertView;

        }

        TextView textView = (TextView) grid.findViewById(R.id.grid_text);
        ImageView imageView = (ImageView)grid.findViewById(R.id.grid_image);
        textView.setText(web[position]);
        imageView.setImageResource(Imageid[position]);

        return grid;
    }

}

这就是我在 mainActivity 中调用 class 的方式:

CustomGrid adapter = new CustomGrid(MainActivity.this, web, imageId);
grid=(GridView)findViewById(R.id.grid);
grid.setAdapter(adapter);

任何帮助将不胜感激谢谢!

    Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.tokom.globol.CustomGrid) [Instantiatable]

这就是我们的线索!只需将默认构造函数添加到 CustomGrid class.

    public CustomGrid() {
    }