0

I have two APKs. First APK is a main APK which loads second APK. In the second APK I have next code:

@Entity
public class RequestEntity {
    @PrimaryKey
    @NonNull
    public String uid;

    @ColumnInfo(name = "bucketName")
    public String bucketName;

    @ColumnInfo(name = "key")
    public String key;

    @ColumnInfo(name = "stream")
    public byte[] stream;

    @ColumnInfo(name = "metadata")
    public byte[] metadata;

    public RequestEntity(String bucketName, String key, byte[] stream, byte[] metadata) {
        this.uid = bucketName + key;
        this.bucketName = bucketName;
        this.key = key;
        this.stream = stream;
        this.metadata = metadata;
    }
}

@Dao
public interface RequestDao {
    @Query("SELECT * FROM requestEntity")
    List<RequestEntity> getAll();

    @Query("SELECT * FROM requestEntity WHERE uid IN (:requestIds)")
    List<RequestEntity> loadAllByIds(int[] requestIds);

    @Insert
    void insert(RequestEntity requestEntitie);

    @Insert
    void insertAll(RequestEntity... requestEntities);

    @Delete
    void delete(RequestEntity user);
}

@Database(entities = {RequestEntity.class}, version = 2, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
    public abstract RequestDao requestDao();
}

My problem is when I call this line in the second APK:

db = Room.databaseBuilder(context, AppDatabase.class, "database-name").build();

I get exception:

java.lang.RuntimeException: cannot find implementation for [my package name].AppDatabase. AppDatabase_Impl does not exist

If I copy my code to main APK and call to this line from main APK, everything OK.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Rougher
  • 834
  • 5
  • 19
  • 46
  • Can you share some more detail? What you are trying to achieve and how you are doing it? It's not very clear from what you have mentioned. When you ask question always try to give as much detail as possible. It help others to understand problem. – TheGraduateGuy Jan 16 '20 at 15:00
  • First main APK loads second APK through DexClassLoader. Then second APK creates AppDatabase for requests. I try to achieve build-in "automatic updates". – Rougher Jan 16 '20 at 15:08
  • Ok. I found another solution for it. I used SQLite API instead of Room API. I still don't know what is problem with Room in reflection... – Rougher Jan 17 '20 at 10:41

0 Answers0