Picasso 正在加载 URL 但没有显示图片

Picasso is loading URL but no picture is shown

我遇到了迄今为​​止最奇怪的问题之一。我正在创建一个应用程序,它通过不同的活动发送有关书籍和作者的信息。我在意图的帮助下发送它们。我的问题在作者部分。我正在发送姓名、年龄和照片。姓名和年龄已成功发送,据我所知,调试器也已成功发送图像。但是,Picasso 拒绝在 ImageView 中加载它。没有显示任何错误,我不知道发生了什么。这是一些代码。

此函数重置我的数据库中的信息:

public void resetAuthor()
    {
        SQLiteDatabase db = this.getWritableDatabase();
        db.execSQL("DELETE FROM " + TABLE_NAME_AUTHORS);
        db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME_AUTHORS + "'");

        addBegginingInfoAuthor("J.K.Rowling", 54, "https://www.biographyonline.net/wp-content/uploads/2014/05/jk-rowling4.jpg");
        addBegginingInfoAuthor("J.R.R. Tolken", 81, "https://www.biography.com/.image/t_share/MTE5NTU2MzE2Mzg4MzYxNzM5/jrr-tolkien-9508428-1-402.jpg");
        addBegginingInfoAuthor("Arthur Conan Doyle", 71, "https://upload.wikimedia.org/wikipedia/commons/b/bd/Arthur_Conan_Doyle_by_Walter_Benington%2C_1914.png");
    }

AuthorAdapter class。这是我的回收者视图的适配器,它显示有关作者的详细信息。这也是我开始打算搬到另一个地方的地方 activity:

@Override
    public void onBindViewHolder(@NonNull AuthorsViewHolder holder, int position) {
        if (!mCursor.moveToPosition(position))
        {
            return;
        }

        final int author_id = mCursor.getInt(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_1));
        final String name = mCursor.getString(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_2));
        final String age = mCursor.getString(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_3));
        final String image = mCursor.getString(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_4));

        holder.authorIndex.setText(String.valueOf(author_id));
        holder.authorName.setText(name);
        holder.authorAge.setText(String.valueOf(age));
        holder.authorName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), displayBooksFromAuthor.class);
                intent.putExtra("Author_id", author_id);
                intent.putExtra("Author_name", name);
                intent.putExtra("Author_age", age);
                intent.putExtra("Author_image", image);
                mContext.startActivity(intent);
            }
        });
    }

最后,我的 DisplayAuthorDetails class 从意图接收数据并显示它:

int author_id = intent.getIntExtra("Author_id", 0);
        String author_name = intent.getStringExtra("Author_name");
        String author_age = intent.getStringExtra("Author_age");
        String author_picture = intent.getStringExtra("Author_image");

        et_name.setText(author_name);
        et_age.setText(author_age);
        et_id.setText(String.valueOf(author_id));
        Picasso.get().load(author_picture).into(author_image);

我有库依赖和清单文件中的两个权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

implementation 'com.squareup.picasso:picasso:2.71828

这个问题最奇怪的部分是,当我创建一个全新的项目并尝试加载它成功加载的图像时。任何帮助表示赞赏。谢谢你的时间

编辑

数据库助手class:

public class DatabaseHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "Books and Authors.db";
    public static final String TABLE_NAME_AUTHORS = "Authors_table";
    public static final String AUTHORS_COL_1 = "Author_ID";
    public static final String AUTHORS_COL_2 = "Name";
    public static final String AUTHORS_COL_3 = "Age";
    public static final String AUTHORS_COL_4 = "Author_picture";
    public static final String TABLE_NAME_BOOKS = "Books_table";
    public static final String BOOKS_COL_1 = "Book_ID";
    public static final String BOOKS_COL_2 = "Author_Foreign";
    public static final String BOOKS_COL_3 = "Title";
    public static final String BOOKS_COL_4 = "Price";


    public DatabaseHelper(Context context) {

        super(context, DATABASE_NAME, null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL("create table " + TABLE_NAME_BOOKS + " (Book_ID INTEGER PRIMARY KEY AUTOINCREMENT, Title TEXT," + "Author_Foreign INT," + "Price TEXT)");
        db.execSQL("create table " + TABLE_NAME_AUTHORS + " (Author_ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT," + "Age INTEGER," + "Author_picture TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_AUTHORS);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_BOOKS);
        onCreate(db);
    }

    public boolean insertDataBooks(String title, float price) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(BOOKS_COL_3, title);
        contentValues.put(BOOKS_COL_4, price);


        long result = db.insert(TABLE_NAME_BOOKS, null, contentValues);


        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public boolean insertDataAuthors(String name, int age) {
        SQLiteDatabase mydb = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(AUTHORS_COL_2, name);
        contentValues.put(AUTHORS_COL_3, age);

        long result = mydb.insert(TABLE_NAME_AUTHORS, null, contentValues);

        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public boolean addBegginingInfo(int foreign_author_id, String title, double price) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(BOOKS_COL_2, foreign_author_id);
        contentValues.put(BOOKS_COL_3, title);
        contentValues.put(BOOKS_COL_4, price);

        long result = db.insert(TABLE_NAME_BOOKS, null, contentValues);

        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public boolean addBegginingInfoAuthor(String name, int age, String image)
    {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(AUTHORS_COL_2, name);
        contentValues.put(AUTHORS_COL_3, age);
        contentValues.put(AUTHORS_COL_4, image);

        long result = db.insert(TABLE_NAME_AUTHORS, null, contentValues);

        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public Integer deleteBook(String index) {
        SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME_BOOKS, "Book_ID = ?", new String[]{index});
    }

    public Integer deleteAuthor(String authorIndex) {
        SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME_AUTHORS, "Author_ID = ?", new String[]{authorIndex});
    }

    public void resetBookTable() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.execSQL("DELETE FROM " + TABLE_NAME_BOOKS);
        db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME_BOOKS + "'");

        addBegginingInfo(1, "Harry Potter", 9.99);
        addBegginingInfo(1, "Fantastic Beasts", 14.99);
        addBegginingInfo(2, "Lord of the Rings", 8.99);
        addBegginingInfo(2, "The Hobbit", 12.99);
        addBegginingInfo(3, "Sherlock Holmes", 6.99);
        addBegginingInfo(3, "Valley of Fear", 7.99);


    }

    public void resetAuthor()
    {
        SQLiteDatabase db = this.getWritableDatabase();
        db.execSQL("DELETE FROM " + TABLE_NAME_AUTHORS);
        db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME_AUTHORS + "'");

        addBegginingInfoAuthor("J.K.Rowling", 54, "https://www.biographyonline.net/wp-content/uploads/2014/05/jk-rowling4.jpg");
        addBegginingInfoAuthor("J.R.R. Tolken", 81, "https://www.biography.com/.image/t_share/MTE5NTU2MzE2Mzg4MzYxNzM5/jrr-tolkien-9508428-1-402.jpg");
        addBegginingInfoAuthor("Arthur Conan Doyle", 71, "https://upload.wikimedia.org/wikipedia/commons/b/bd/Arthur_Conan_Doyle_by_Walter_Benington%2C_1914.png");
    }
}

经过几个小时的尝试,我终于发现要解决这个问题,我只需要在模拟器上重新安装应用程序即可。