То, как Вы создаете отладку .exe (MSVCRTD.lib) против выпуска, создало lib (MSVCRT.lib)?

Хорошо. Попробуйте это: создайте какой-нибудь класс, который, как я вижу, у вас есть Изображение и имя, а Имя класса - Категория:

public class Category {
private String CategoryName;   
private String CategoryImage;


public Category() {
}

public Category(String categoryName, String categoryImage) {
    CategoryName = categoryName;       
    CategoryImage = categoryImage;

}

public String getCategoryName() {
    return CategoryName;
}

public void setCategoryName(String categoryName) {
    CategoryName = categoryName;
}

public String getCategoryImage() {
    return CategoryImage;
}

public void setCategoryImage(String categoryImage) {
    CategoryImage = categoryImage;
}}

И еще одно упражнение с recyclerView

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Category_List">

<android.support.v7.widget.RecyclerView
    android:id="@+id/category_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:listitem="@layout/category_item" />

И один файл ресурсов макета с просмотром карты, в котором отображается элемент категории

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">

<RelativeLayout
    android:id="@+id/category_relative_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/category_image_item"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_marginBottom="8dp"
        android:scaleType="centerCrop"
        app:srcCompat="@drawable/ic_image" />

    <TextView
        android:id="@+id/category_name_item"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/category_image_item"
        android:layout_alignParentStart="true"
        android:layout_marginStart="8dp"
        android:layout_marginBottom="8dp"
        android:text="TextView"
        android:textSize="24sp" />
</RelativeLayout>

NextPap Category

public class CategoryAdapter extends FirestoreRecyclerAdapter<Category, CategoryAdapter.CategoryHolder> {
private OnItemClickListener listener;
public CategoryAdapter(@NonNull FirestoreRecyclerOptions<Category> options) {
    super(options);
}
@Override
protected void onBindViewHolder(@NonNull CategoryHolder holder, int position, @NonNull Category model) {
    holder.CategoryName.setText(model.getCategoryName());       
    Picasso.get().load(model.getCategoryImage()).error(R.drawable.ic_image).placeholder(R.drawable.ic_image).into(holder.CategoryImage);    }

@NonNull
@Override
public CategoryHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.category_item, viewGroup, false);
    return new CategoryHolder(v);
}


public class CategoryHolder extends RecyclerView.ViewHolder {
    public TextView CategoryName;        
    public ImageView CategoryImage;        

    public CategoryHolder(@NonNull View itemView) {
        super(itemView);
        CategoryName = itemView.findViewById(R.id.category_name_item);            
        CategoryImage = itemView.findViewById(R.id.category_image_item);   

        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int position = getAdapterPosition();
                if (position != RecyclerView.NO_POSITION && listener != null) {
                    listener.onItemClick(getSnapshots().getSnapshot(position), position);
                }
            }
        });
    }
}

public interface OnItemClickListener {
    void onItemClick(DocumentSnapshot documentSnapshot, int position);
}

public void setOnItemClickListener(CategoryAdapter.OnItemClickListener listener) {
    this.listener = listener;
}

}

[ 1112] В MainActivity настройте окно повторного просмотра: сверху после метода создания создайте ссылку на Adapter,

public class MainActivity extends AppCompatActivity {
private FirebaseFirestore db = FirebaseFirestore.getInstance();
private CollectionReference categoryRef = db.collection("category_tbl");

public CategoryAdapter categoryAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_category__list);
    setTitle(R.string.category_list_title);
    setUpRecyclerView();
}

private void setUpRecyclerView() {
    Query query = categoryRef.orderBy("categoryPrior", Query.Direction.DESCENDING);
    final FirestoreRecyclerOptions<Category> category_options = new FirestoreRecyclerOptions.Builder<Category>()
            .setQuery(query, Category.class).build();

    categoryAdapter = new CategoryAdapter(category_options);
    RecyclerView recyclerView = findViewById(R.id.category_recycler_view);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(categoryAdapter);

}

@Override
protected void onStart() {
    super.onStart();
    categoryAdapter.startListening();
}

@Override
protected void onStop() {
    super.onStop();
    categoryAdapter.stopListening();
}

В конце попробуйте добавить некоторые данные непосредственно в FiredatabaseFiresotre и посмотреть, отображается ли оно.

5
задан ApplePieIsGood 14 April 2009 в 04:24
поделиться

2 ответа

Вы можете создать свой проект, чтобы связать его с CRT-релизом и включить отладочную информацию для вашего кода. В «Свойствах проекта» перейдите на C ++ / General и измените формат информации отладки. В разделе «Оптимизация» отключите оптимизацию. Перейдите в раздел «Linker / Debugging» и включите генерацию отладочной информации. Обязательно установите файл базы данных программы (PDB).

На этом этапе ваше приложение будет выдавать отладочную информацию для всего, что есть в вашем коде, и связываться с неотладочной библиотекой DLL CRT. Это позволяет вам отлаживать приложение в конфигурации выпуска, избегая проблем, связанных с использованием нескольких CRT в одном приложении.

10
ответ дан 13 December 2019 в 05:42
поделиться

I have seen similar problems to this when mixing and matching Debug and Release configuration libraries.

While this can sometimes work, it can also result in obscure crashes such as the one you are seeing (possibly caused by mismatched entry points or something similar).

The alternatives as I see them are:

  • Build your application in Release configuration (pointing it to MSVCRT.dll) and see if this works (you won't be able to get as much debugging info, but it might help isolate the source of the problem).

  • If the 3rd party library is open-source, try building the Debug version of the .lib file yourself.

  • Otherwise, see if the Debug version is available online, or contact the vendor.

Sorry I couldn't be of more help. I think it will be quicker in the long run if you can get access to the correct libraries then trying to figure out ways to work around it.

2
ответ дан 13 December 2019 в 05:42
поделиться
Другие вопросы по тегам:

Похожие вопросы: