gpt4 book ai didi

java - Android成功构建了gradle但没有在模拟器上安装应用程序

转载 作者:行者123 更新时间:2023-12-04 00:30:25 26 4
gpt4 key购买 nike

我在使用 Android 架构组件时遇到了一些问题。我想做的是从 View 模型中,我将执行存储库类中的函数。这是我的 View 模型:

private final ReservationRepository reservationRepository;
private final UserRepository userRepository;
private LiveData<List<ReservationEntity>> reservations;

@Inject
public ReservationViewModel(ReservationRepository reservationRepository, UserRepository userRepository) {
this.reservationRepository = reservationRepository;
this.userRepository = userRepository;
reservations = reservationRepository.loadReservations();
}

public LiveData<List<ReservationEntity>> getAllReservations() {
return reservations;
}

然后在我的存储库类中:
private final ReservationDao reservationDao;

@Inject
public ReservationRepository(ReservationDao reservationDao) {
this.reservationDao = reservationDao;
}

public LiveData<List<ReservationEntity>> loadReservations() {
return reservationDao.getAllReservation();
}

在我的 DAO 类(class)中:
@Query("SELECT * FROM reservation")
LiveData<List<ReservationEntity>> getAllReservation();

我有一个 AppModule 来@Provide @Inject:
@Provides
@Singleton
ReservationDatabase provideReservationDatabase(Application application) {
return Room.databaseBuilder(application,ReservationDatabase.class,
ReservationDatabase.DATABASE_NAME).allowMainThreadQueries().build();
}

@Provides
@Singleton
ReservationDao provideReservationDao(ReservationDatabase reservationDatabase) {
return reservationDatabase.reservationDao();
}

我成功地构建了这个项目。但是,在成功构建 gradle 后,它不会将应用程序安装到模拟器上。有任何想法吗?

谢谢!

最佳答案

就我而言,Gradle Sync解决了这个问题。

关于java - Android成功构建了gradle但没有在模拟器上安装应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52067747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com