Room database is not working in mac book pro m1 - android

Room database is not working in mac book pro m1
i have already added id 'kotlin-kapt'
screen shoot of android studio console log
What went wrong: 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)
Caused by: java.lang.reflect.InvocationTargetException at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90)
at
org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:31)
at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45) ... 31 more
Caused by: java.lang.Exception: No native library is found for
os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64
at
org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:333)
at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:64)
at
androidx.room.verifier.DatabaseVerifier.(DatabaseVerifier.kt:71)
... 50 more

Simply use Room 2.4.0-alpha03
def room_version = "2.4.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
Edit : The answer consisted of two solutions to solve the issue , since the above written solution was successful for many ,the other solution is removed .

add dependency:
kapt "org.xerial:sqlite-jdbc:3.34.0"

Related

Anddroid: Execution failed for task ':libhos:kaptKotlin'

How can I resolve this error, I get this after upgrading my kotlin to 1.6.10
Is there any concrete way resolve this
Caused by: java.lang.IllegalStateException: Could not parse metadata! This should only happen if you're using Kotlin <1.1.
at com.squareup.moshi.kotlinpoet.metadata.KotlinPoetMetadata.readKotlinClassMetadata(KotlinPoetMetadata.kt:83)
at com.squareup.moshi.kotlinpoet.metadata.KotlinPoetMetadata.toImmutableKmClass(KotlinPoetMetadata.kt:113)
at com.squareup.moshi.kotlin.codegen.MoshiCachedClassInspector.toImmutableKmClass(MoshiCachedClassInspector.kt:37)
at com.squareup.moshi.kotlin.codegen.MetadataKt.targetType(metadata.kt:137)
at com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor.adapterGenerator(JsonClassCodegenProcessor.kt:148)
at com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor.process(JsonClassCodegenProcessor.kt:114)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:188)

How to resolve this error: Caused by: java.lang.IllegalArgumentException: com.example.MyClassName does not represent a declared type?

I am getting this error while building my Kotlin/Android application?
Caused by: java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor812.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:31)
at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
... 30 more
Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.IllegalArgumentException: com.example.MyClassName does not represent a declared type
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:992)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1335)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
... 35 more
Caused by: java.lang.IllegalArgumentException: com.example.MyClassName does not represent a declared type
at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:948)
at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:939)
at jdk.compiler/com.sun.tools.javac.code.Type$ErrorType.accept(Type.java:2394)
at dagger.shaded.auto.common.MoreTypes.asDeclared(MoreTypes.java:579)
at dagger.internal.codegen.base.Keys$1.visitDeclared(Keys.java:89)
at dagger.internal.codegen.base.Keys$1.visitDeclared(Keys.java:66)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1151)
at dagger.internal.codegen.base.Keys.isValidImplicitProvisionKey(Keys.java:65)
at dagger.internal.codegen.base.Keys.isValidImplicitProvisionKey(Keys.java:50)
I am using dagger2 for dependency injection, in my application, the application uses a module that has a dependency on another module. What should be the correct way to resolve this dependency?
You'll need an implementation dependency on the module you're consuming, but the recent build flag enableAggregatingTask will do so automatically.
Per google/dagger#2123, bcorso responding to Kshitij09 in November 2020:
You mean I either app should have direct dependency (adding implementation) on :libraryB or :libraryA have api dependency on :libraryB right?
Hi #Kshitij09, yes that's the current solution and we're looking into ways to improve this (see #1991 (comment))
In that same thread, bcorso updates in September 2021:
If you're using Hilt (with Gradle) the solution is to use the Hilt Gradle plugin and then enable the aggregating task in your build.gradle modules:
hilt {
enableAggregatingTask = true
}
The enableAggregatingTask build configuration was introduced in Dagger 2.37 in June 2021 and enabled by default in Dagger 2.40 in October 2021.

Update Gradle to Version 7.0.2

Updating Gradle from version 4.2.0 to 7.0.2. ended up in an error during minifying with R8. (Using Java 1.8)
Unfortunately, the error message is not very telling (see below).
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at Version.fakeStackEntry(Version_3.0.69.java:0)
at com.android.tools.r8.utils.w.a(SourceFile:68)
at com.android.tools.r8.utils.w.a(SourceFile:28)
at com.android.tools.r8.utils.w.a(SourceFile:27)
at com.android.tools.r8.R8.a(R8.java:29)
at com.android.tools.r8.R8.run(R8.java:3)
at com.android.builder.dexing.R8Tool.runR8(r8Tool.kt:301)
at com.android.build.gradle.internal.tasks.R8Task$Companion.shrink(R8Task.kt:592)
at com.android.build.gradle.internal.tasks.R8Task.doTaskAction(R8Task.kt:443)
at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:63)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction(NonIncrementalTask.kt:94)
at jdk.internal.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
... 118 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.android.tools.r8.graph.B.F()" because "<parameter1>" is null
Did anybody face / solve the same problem?

Resource linking fails on lStar with error

I'm working on a android Native application. My Android builds began to fail without any changes.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':etndoorcontrol:processHesuan_faceDebugResources'.
> Android resource linking failed
C:\Users\xqf\.gradle\caches\transforms-2\files-2.1\fe7b90aa462d9a2e04dd8216aa450a51\res\values\values.xml:2422:5-2449:25: AAPT: error: resource android:attr/lStar not found.
error: failed linking references.
Then I tried 2 solutions
//soultion 1.
configurations.all {
resolutionStrategy {
// Java language implementation
force "androidx.core:core:1.6.0"
// Kotlin
force "androidx.core:core-ktx:1.6.0"
}
}
After I add this to app/build.gradle, the app can build correct.but after I install the apk and run .there is a new problem.
java stacktrace:
java.lang.NoClassDefFoundError: androidx.appcompat.widget.Toolbar
at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
at java.lang.Class.getDexCacheType(Class.java:2551)
at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:169)
at java.lang.reflect.Method.getParameterTypes(Method.java:193)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:163)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingInfo(SubscriberMethodFinder.java:88)
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:64)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:140)
at com.yarward.a10doorcontrol.homepage.HomePageActivity.initFields(HomePageActivity.java:334)
at com.yarward.base.mvp.view.BaseActivity.onCreate(BaseActivity.java:82)
at com.yarward.a10doorcontrol.homepage.HomePageActivity.onCreate(HomePageActivity.java:257)
at android.app.Activity.performCreate(Activity.java:6709)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2628)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2736)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1487)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6157)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
Caused by: java.lang.ClassNotFoundException: androidx.appcompat.widget.Toolbar
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
... 22 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/view/MenuHost;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
at java.lang.Class.getDexCacheType(Class.java:2551)
at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:169)
at java.lang.reflect.Method.getParameterTypes(Method.java:193)
at java.lang.Class.getDeclaredMethods(Class.java:1812)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:154)
... 18 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.MenuHost" on path: DexPathList[[zip file "/data/app/com.yarward.hesuanface-1/base.apk"],nativeLibraryDirectories=[/data/app/com.yarward.hesuanface-1/lib/arm, /data/app/com.yarward.hesuanface-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 28 more
After this, I tried the other solution, as below:
ext{
androidX = 1.6.0
}
but this is not working for me.
axel8888 thank your sir, yes, I have solved this problem. yes, you are right , when I try solution one again
configurations.all {
resolutionStrategy {
// Java language implementation
force "androidx.core:core:1.6.0"
// Kotlin
force "androidx.core:core-ktx:1.6.0"
}
}
and as you the problem is now in
androidx.appcompat:appcompat:1.4.0-alpha
so I checked the gradle dependencies, yes , even I used
androidx.appcompat:appcompat:1.3.1
but my project shows the version is 1.4.0-alpha. here is my solution
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == "androidx.appcompat") {
if (requested.name == "appcompat") {
details.useVersion "1.3.1"
}
}
}
}
and it worked, now my project can build and run correctly, thank you, sir!
Obveiously the problem is now in androidx.appcompat:appcompat:1.4.0-alpha. If your UI use Toolbar, you will get the MenuHost not found crash.BUT, evenif I use resolutionStrategy to force 'androidx.appcompat:appcompat:1.3.1', dependency still make it toandroidx.appcompat:appcompat:{strictly 1.4.0-beta01}
It still confuse me a lot.
SOLVED -- someone write a update code for appcompat before... now it can force to 1.3.1 and solve the problem
change
implementation 'androidx.appcompat:appcompat:1.4.0'
to
implementation 'androidx.appcompat:appcompat:1.3.1'
that's it
implementation 'androidx.appcompat:appcompat:1.4.1'
was causing the problem, going back to 1.3.1 worked.
implementation 'androidx.appcompat:appcompat:1.3.1'
ill update once I get an official solution.

Migrate to Jetpack compose error: Unbound symbols not allowed

I wanted to migrate my existing project to partially use Jetpack compose for it.
So I opened it using Android studio 4.2-canary9 and added a compose activity so that Android studio adds needed configurations needed.
When I tried to run the project it gave me an error:
e: java.lang.AssertionError: Unbound symbols not allowed
Using Run with --stacktrace I have this stacktrace thrown at me:
e: java.lang.AssertionError: Unbound symbols not allowed
Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/state.<get-state>|-5663767092261428579[0]
Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/stateContainer.<get-stateContainer>|-4335442114828357571[0]
Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/list.<get-list>|9139041782698166288[0]
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:96)
at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFiles(JvmBackendFacade.kt:87)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:40)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:616)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:203)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:51)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:346)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:102)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:240)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:39)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:81)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:93)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:601)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:93)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1633)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
The first route mentions activity_main which is an activity not made using compose. It refers to Kotlin android extensions which is used to replace findViewById (state is a TextView ID)
Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/state.<get-state>|-5663767092261428579[0]
Here are some configurations:
compose: 1.0.0-alpha02 & 1.0.0-alpha04
kotlin: 1.4.0 & 1.4.10
android-gradle-plugin: 4.2.0-alpha09 & 4.2.0-alpha13
kotlin-stdlib: either jdk8 and jdk7
Thanks in advance
I had the same problem. As a workaround, I replaced all Kotlin synthetic with ViewBinding. After I did it everything worked.
Apparently, this issue has been fixed and will be shipped to Kotlin:1.4.20 (Which is not released at the time)
Google issue tracker reference
Kotlin Pull request
[Update at 27 Nov]
Updating to 1.4.20 leads to another error [Ref]
I had a similar problem when I was migrating a template project. What fixed it for me was deleting some template code that accessed elements that were grabbed by findbyviewid.
I have to choose the other way around for this case,
composeOptions {
kotlinCompilerExtensionVersion "1.1.0-beta03"
}
I also have to downgrade the Kotlin version for this.
ext.kotlin_version = "1.5.31"
ext.compose_version = '1.1.1'

Categories

Resources