如果添加以下行,则在创建新的Android Studio项目(“空活动”类型)后:
// Lifecycle/View Models
def lifecycleVersion = '2.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycleVersion"
// Core testing
def coreTestingVersion = '2.0.1'
testImplementation "androidx.arch.core:core-testing:$coreTestingVersion"
androidTestImplementation "androidx.arch.core:core-testing:$coreTestingVersion"
Run Code Online (Sandbox Code Playgroud)
对于应用程序的build.gradle文件,当您尝试运行connectedCheck项目任务时会看到错误。查看输出:
Zachs-MBP:CoreTestingVersionExample Zach$ ./gradlew connectedCheck
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugAndroidTestBuild'.
> Could not resolve all task dependencies for configuration ':app:debugAndroidTestRuntimeClasspath'.
> Could not resolve androidx.arch.core:core-common:2.0.0.
Required by:
project :app
> Cannot find a version of 'androidx.arch.core:core-common' that satisfies the …Run Code Online (Sandbox Code Playgroud) 在添加Room db依赖关系并使用我的应用程序对其进行配置后,我遇到了一些错误,其中大部分是Failed to read get kotlin metadata for...尽管我没有在项目中使用kotlin,第二个错误是关于TypeConverter变量的,private List<String> labels;我正在做一些关于如何添加List或ArrayList作为TypeConverter,但是我没有为此感到灵魂
> Task :app:processDebugAnnotationsWithJavac
D:\Courses\Java\Android Projects\ProCSIS\app\src\main\java\www\pro_cs_is\com\Item.java:20: Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@2f693bda
public class Item implements Serializable {
^
D:\Courses\Java\Android Projects\ProCSIS\app\src\main\java\www\pro_cs_is\com\Item.java:67: error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.
private List<String> labels;
^
D:\Courses\Java\Android Projects\ProCSIS\app\src\main\java\www\pro_cs_is\com\ItemDao.java:13: Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@5179217e
@Insert
^
D:\Courses\Java\Android Projects\ProCSIS\app\src\main\java\www\pro_cs_is\com\Item.java:20: Note: Failed to read …Run Code Online (Sandbox Code Playgroud) android android-gradle-plugin android-room android-jetpack androidx