GVKun编程网logo

当我创建 Moshi 数据类时,任务 ':app:kaptDebugKotlin' 执行失败

1

对于想了解当我创建Moshi数据类时,任务':app:kaptDebugKotlin'执行失败的读者,本文将提供新的信息,并且为您提供关于androidstudio未执行代码并抛出错误,提示“任务':

对于想了解当我创建 Moshi 数据类时,任务 ':app:kaptDebugKotlin' 执行失败的读者,本文将提供新的信息,并且为您提供关于android studio 未执行代码并抛出错误,提示“任务':app:compileDebugJavaWithJavac' 执行失败”、Android Studio 构建失败“任务 ':app:kaptDebugKotlin' 的执行失败”、flutter 中的任务 ':app:stripDebugDebugSymbols' 执行失败、Flutter:任务“:app:processDebugResources”执行失败的有价值信息。

本文目录一览:

当我创建 Moshi 数据类时,任务 ':app:kaptDebugKotlin' 执行失败

当我创建 Moshi 数据类时,任务 ':app:kaptDebugKotlin' 执行失败

如何解决当我创建 Moshi 数据类时,任务 '':app:kaptDebugKotlin'' 执行失败

当我创建 moshi 数据类时,它没有正确构建 以下是我尝试构建时的错误

Execution Failed for task '':app:kaptDebugKotlin''.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


这是我使用 Json 到 Kotlin 插件的数据类

@JsonClass(generateAdapter = true)
data class FCMResponse(
    @Json(name = "canonical_ids")
    val canonicalIds: Int = 0,@Json(name = "failure")
    val failure: Int = 0,@Json(name = "multicast_id")
    val multicastId: Long = 0,@Json(name = "results")
    val results: List<Result> = listof(),@Json(name = "success")
    val success: Int = 0
)

解决方法

如果您使用的是 kotlin 1.5 版,请按如下方式更新依赖项:

  • 房间到:2.3.0
  • 匕首/刀柄:2.35.1
  • Moshi 到:1.12.0

check this question

android studio 未执行代码并抛出错误,提示“任务':app:compileDebugJavaWithJavac' 执行失败”

android studio 未执行代码并抛出错误,提示“任务':app:compileDebugJavaWithJavac' 执行失败”

如何解决android studio 未执行代码并抛出错误,提示“任务'':app:compileDebugJavaWithJavac'' 执行失败”

所以我新安装了 android studio 并尝试运行默认代码。但是我一直收到一个错误,说必须使用 JDK 而不是 JRE (Java)。进行这些更改后,我收到了这个新错误提示

  1. ptr

请帮忙!我什至尝试卸载并重新安装工作室,但弹出相同的错误!

Android Studio 构建失败“任务 ':app:kaptDebugKotlin' 的执行失败”

Android Studio 构建失败“任务 ':app:kaptDebugKotlin' 的执行失败”

如何解决Android Studio 构建失败“任务 '':app:kaptDebugKotlin'' 的执行失败”

我收到此错误,我想我明白它的来源,但我不明白问题所在。我收到的错误的详细摘要。

  1. > Task :app:kaptDebugKotlin
  2. C:\\Users\\matan\\AndroidStudioProjects\\RoomTut\\app\\build\\tmp\\kapt3\\stubs\\debug\\com\\example\\roomtut\\data\\MarkerDao.java:13: error: Type of the parameter must be a class annotated with @Entity or a collection/array of it.
  3. kotlin.coroutines.Continuation<? super kotlin.Unit> p1);
  4. ^C:\\Users\\matan\\AndroidStudioProjects\\RoomTut\\app\\build\\tmp\\kapt3\\stubs\\debug\\com\\example\\roomtut\\data\\MarkerDao.java:11: error: Not sure how to handle insert method''s return type.
  5. public abstract java.lang.Object addMarker(@org.jetbrains.annotations.NotNull()
  6. ^[WARN] Incremental annotation processing requested,but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).
  7. > Task :app:kaptDebugKotlin Failed
  8. FAILURE: Build Failed with an exception.
  9. * What went wrong:
  10. Execution Failed for task '':app:kaptDebugKotlin''.
  11. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
  12. > java.lang.reflect.InvocationTargetException (no error message)
  13. * Try:
  14. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  15. * Get more help at https://help.gradle.org
  16. BUILD Failed in 32s
  17. 29 actionable tasks: 9 executed,20 up-to-date

我知道我的标记 dao 中存在问题,但对我而言,注释看起来不错,您可以在下面看到,还有指向我的完整项目的存储库的链接 - https://github.com/M-J-Y-21/room-test

  1. import androidx.lifecycle.LiveData
  2. import androidx.room.Dao
  3. import androidx.room.Insert
  4. import androidx.room.OnConflictStrategy
  5. import androidx.room.Query
  6. @Dao
  7. interface MarkerDao {
  8. @Insert(onConflict = OnConflictStrategy.IGnorE)
  9. suspend fun addMarker(marker: Marker)
  10. @Query("SELECT * FROM marker_table ORDER BY id ASC")
  11. fun readAllData(): LiveData<List<Marker>>
  12. }

您可以在下面看到我是如何注释标记类的

  1. import androidx.room.Entity
  2. import androidx.room.PrimaryKey
  3. @Entity(tableName = "marker_table") data class Marker(
  4. @PrimaryKey(autoGenerate = true)
  5. val id: Int,val title: String,val location: String,val colour: String
  6. )

下面是我的数据库类

  1. import android.content.Context
  2. import androidx.room.Database
  3. import androidx.room.Room
  4. import androidx.room.RoomDatabase
  5. @Database(entities = arrayOf(Marker::class),version = 1,exportSchema = false)
  6. abstract class MarkerDatabase: RoomDatabase() {
  7. abstract fun markerDao(): MarkerDao
  8. companion object {
  9. @Volatile
  10. private var INSTANCE: MarkerDatabase? = null
  11. fun getDatabase(context: Context): MarkerDatabase{
  12. val tempInstance = INSTANCE
  13. if (tempInstance != null) {
  14. return tempInstance
  15. }
  16. synchronized(this) {
  17. val instance = Room.databaseBuilder(
  18. context.applicationContext,MarkerDatabase::class.java,"marker_database"
  19. ).build()
  20. INSTANCE = instance
  21. return instance
  22. }
  23. }
  24. }
  25. }

解决方法

正如我所见,您的项目使用了不同版本的 androidx.room 依赖项,例如:

  1. "androidx.room:room-runtime:2.3.0"
  2. "androidx.room:room-compiler:2.2.5"

您应该为所有 androidx.room 的工件使用类似的版本。 Please look at sample with more right approach:

  1. dependencies {
  2. ...
  3. def room_version = "2.3.0"
  4. implementation "androidx.room:room-runtime:$room_version"
  5. annotationProcessor "androidx.room:room-compiler:$room_version"
  6. kapt "androidx.room:room-compiler:$room_version"
  7. ...
  8. }

当我将 androidx.room 的所有版本更改为 2.3.0 时,一切正常。并且不要忘记更改 addMarker 的返回类型:

  1. @Insert(onConflict = OnConflictStrategy.IGNORE)
  2. suspend fun addMarker(marker: Marker) // OK
  3. @Insert(onConflict = OnConflictStrategy.IGNORE)
  4. suspend fun addMarker(marker: Marker): Long // OK
  5. @Insert(onConflict = OnConflictStrategy.IGNORE)
  6. suspend fun addMarker(marker: Marker): Int // ERROR

我是如何寻找问题的:

  1. 检查 @Insert 方法的返回类型(见上文)。
  2. 检查参数的类型和插入方法的注释(@Entity)。
  3. 检查导入:IDE 可以自动添加名称相似但来自其他包的导入类或注解。
  4. Check setup of database。
  5. Check project dependencies(or other doc''s sample)。

附言您通过 MarkerDatabase.Companion.getDatabase() 实现的单例是错误的 :( 请使用双重检查锁定算法,或将所有方法设为同步或尝试根据您的情况调整 kotlin 的 lazy

flutter 中的任务 ':app:stripDebugDebugSymbols' 执行失败

flutter 中的任务 ':app:stripDebugDebugSymbols' 执行失败

如何解决flutter 中的任务 '':app:stripDebugDebugSymbols'' 执行失败

当我尝试在设备上运行我的 Flutter 应用程序时,我的构建未能给出此错误

  1. > Execution Failed for task '':app:stripDebugDebugSymbols''.
  2. > NDK at C:\\Users\\User\\AppData\\Local\\Android\\sdk\\ndk-bundle did not have a source.properties file

我已尝试通过 [this][1] 解决此问题。但它没有用。 我有 ndk 版本 23.0.7421159rc5 已安装。 这是颤振医生的结果

  1. >[√] Flutter (Channel stable,2.0.5,on Microsoft Windows [Version 10.0.19042.985],locale en-US)<br>
  2. >[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)<br>
  3. >[√] Chrome - develop for the web<br>
  4. >[!] Android Studio (version 4.0)<br>
  5. X Unable to find bundled Java version.<br>
  6. >[√] Android Studio (version 4.1.0)<br>
  7. [√] VS Code (version 1.57.1)<br>
  8. [√] Connected device (3 available)

请帮忙解决问题

https://github.com/facebook/react-native/issues/28404

解决方法

进入您的 SDK 位置并找到名为 ndk 的目录,然后删除该目录中的内容。然后再次构建应用程序。可能 ndk 版本已损坏,Android Studio 会将其替换为最新版本。

Flutter:任务“:app:processDebugResources”执行失败

Flutter:任务“:app:processDebugResources”执行失败

如何解决Flutter:任务“:app:processDebugResources”执行失败

当我尝试在 Android 上构建我的 Flutter 应用程序时收到此错误消息。自从我几天前开始这个项目以来,它运行良好。在 IOS 模拟器上做了一些测试后,我不得不再次在 Android 上尝试一些东西,但无法再构建它。

Launching lib/main.dart on AOSP on IA Emulator in debug mode...

FAILURE: Build Failed with an exception.

* What went wrong:
Execution Failed for task '':app:processDebugResources''.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking Failed
     ERROR:/Users/Antonio/DropBox/Flutter/wader/build/app/intermediates/packaged_manifests/debug/AndroidManifest.xml:22: AAPT: error: ''orientation|keyboardHidden|keyboard|viewsize|smallestviewsize|locale|layoutDirection|fontScale|screenLayout|density|uiMode'' is incompatible with attribute configChanges (attr) flags [colorMode=16384,density=4096,fontScale=1073741824,keyboard=16,keyboardHidden=32,layoutDirection=8192,locale=4,mcc=1,mnc=2,navigation=64,orientation=128,screenLayout=256,screenSize=1024,smallestScreenSize=2048,touchscreen=8,uiMode=512].


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD Failed in 1m 40s
The build Failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin connectivity...

FAILURE: Build Failed with an exception.

* What went wrong:
Task ''assembleAarRelease'' not found in root project ''connectivity''.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD Failed in 4s
Exception: The plugin connectivity Could not be built due to the issue above.
Exited (sigterm)

这是我的颤振医生:

Doctor summary (to see all details,run Flutter doctor -v):
[✓] Flutter (Channel stable,2.2.2,on Mac OS X 10.15.7 19H1030 darwin-x64,locale en-AE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.44.0)
[✓] VS Code (version 1.43.2)
[✓] Connected device (2 available)

• No issues found!

有什么想法吗?

我们今天的关于当我创建 Moshi 数据类时,任务 ':app:kaptDebugKotlin' 执行失败的分享已经告一段落,感谢您的关注,如果您想了解更多关于android studio 未执行代码并抛出错误,提示“任务':app:compileDebugJavaWithJavac' 执行失败”、Android Studio 构建失败“任务 ':app:kaptDebugKotlin' 的执行失败”、flutter 中的任务 ':app:stripDebugDebugSymbols' 执行失败、Flutter:任务“:app:processDebugResources”执行失败的相关信息,请在本站查询。

本文标签: