Status Update
Comments
jg...@google.com <jg...@google.com>
je...@google.com <je...@google.com>
je...@google.com <je...@google.com> #2
au...@google.com <au...@google.com> #3
je...@google.com <je...@google.com> #4
private void refreshAllLiveData() {
AppDataBase YOUR_DATABASE_WHICH_YOU_BUILD = .....
SupportSQLiteDatabase writableDatabase = YOUR_DATABASE_WHICH_YOU_BUILD.getOpenHelper().getWritableDatabase();
//get the database count;
Cursor cursor = writableDatabase.query("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name != 'android_metadata' AND name != 'room_master_table';");
int tableCount = 0;
while(cursor.moveToNext()) {
tableCount = cursor.getInt(0);
}
for (int i = 0; i < tableCount; i++) {
//update version table with the incremented count because room modification log stores tables with ids instead of names
writableDatabase.execSQL("INSERT OR REPLACE INTO room_table_modification_log VALUES(null, "+(i)+")");
}
YOUR_DATABASE_WHICH_YOU_BUILD.getInvalidationTracker().refreshVersionsAsync();
}
-----
This is a workaroud for refreshing all live datas, I still prefer to use a proper API you implemented.
Thanx
au...@google.com <au...@google.com> #5
au...@google.com <au...@google.com> #6
This is how we use it now for application projects
au...@google.com <au...@google.com> #7
Note, to work around it we have to poke into internals of AGP APIs.
extensions.findByType(TestAndroidComponentsExtension::class.java)?.apply {
onVariants(selector().all()) { variant ->
tasks.named(
"${AndroidXImplPlugin.GENERATE_TEST_CONFIGURATION_TASK}${variant.name}",
GenerateTestConfigurationTask::class.java
) { task ->
task.appLoader.set(variant.artifacts.getBuiltArtifactsLoader())
// The target app path is defined in the targetProjectPath field in the android
// extension of the test module
val targetProjectPath =
project.extensions.getByType(TestExtension::class.java).targetProjectPath
?: throw IllegalStateException(
"""
Module `$path` does not have a targetProjectPath defined.
"""
.trimIndent()
)
task.outputAppApk.set(outputAppApkFile(variant, targetProjectPath, path))
task.appFileCollection.from(
configurations
.named("${variant.name}TestedApks")
.get()
.incoming
.artifactView {
it.attributes { container ->
container.attribute(
AndroidArtifacts.ARTIFACT_TYPE,
ArtifactType.APK.type
)
}
}
.files
)
}
}
}
having to use
import com.android.build.gradle.internal.attributes.VariantAttr
import com.android.build.gradle.internal.publishing.AndroidArtifacts
import com.android.build.gradle.internal.publishing.AndroidArtifacts.ArtifactType
au...@google.com <au...@google.com> #8
Any updates here?
je...@google.com <je...@google.com> #9
no news, it's on the backlog though
ak...@google.com <ak...@google.com> #10
Probably we will need something similar for privacy sandbox artifacts as well.
Context: For macrobenchmarks of privacy sandbox projects on Jetpack CI we will need to extract not only test app APK, but also privacy sandbox dependencies (SDKs, splits, etc).
Privacy Sandbox artifacts will be exposed in
je...@google.com <je...@google.com> #11
Amit, looks like we need a more extensible solution than what I suggested in
am...@google.com <am...@google.com> #12
TestExtension now exposes
an...@google.com <an...@google.com> #13
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Ladybug Feature Drop | 2024.2.2 Canary 2
- Android Gradle Plugin 8.8.0-alpha02
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
AGP should expose a BuiltArtifactLoader for target project apk in com.android.test projects.
If we have a project that uses
plugins { id("com.android.test") }
and specifiesit would be great to have an api similar to