VerifyError: Verifier rejected class ... 'this' arg must be initialized - android

after third-party library upgrade I got a new crash on app launch:
java.lang.VerifyError: Verifier rejected class ly.img.android.e: void ly.img.android.e.<init>(java.lang.String, boolean) failed to verify: void ly.img.android.e.<init>(java.lang.String, boolean): [0x5C] 'this' arg must be initialized (declaration of 'ly.img.android.e' appears in base.apk!classes2.dex)
at ly.img.android.b.<clinit>(Unknown Source:46)
at ly.img.android.c.b(Unknown Source:0)
at ly.img.android.PESDK.initSDK(Unknown Source:0)
at ly.img.android.IMGLYAutoInit.onCreate(IMGLYAutoInit.java:41)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
Yes, I know that there are a lot of similar problems there but I didn't find any solution or advise for me.
So, maybe someone there can provide hint or advise for me what's wrong there. Thanks

Others were also facing this kind of issue, I think this can help you! ⛅
java.lang.VerifyError: Verifier rejected class ly.img.android.e: void ly.img.android.e.<init>(java.lang.String, boolean) failed to verify: void ly.img.android.e.<init>(java.lang.String, boolean): [0x5C] 'this' arg must be initialized (declaration of 'ly.img.android.e' appears in base.apk!classes2.dex)
But according to a GitHub thread they found a solution to this problem
https://github.com/CleverTap/clevertap-android-sdk/issues/15#issuecomment-454842450
The fix for this issue is available for AGP(Android Gradle Plugin) 3.3 (and 3.4) by setting an explicit dependency detailed below.
After AGP 3.3.1 is released, remove the pinned version to allow you to pick up new D8/R8 releases again.
For AGP 3.3 amend your top-level build.gradle file with:
buildscript {
repositories {
maven {
url "http://storage.googleapis.com/r8-releases/raw" // ADD THIS.
}
}
dependencies {
classpath 'com.android.tools:r8:1.3.52' // ADD THIS. Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:3.3'
}
}
For AGP 3.4 the r8 version should be 1.4.25

I have a suggestion
Maybe it will help
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
and
implementation 'com.android.support:multidex:1.0.0'

How did I resolve the issue:
I have upgraded gradle version from 3.5.3 to 3.6.3. Ough and thank you. Maybe my experience can help somebody.

I think this is the probelm with third-party library.
In my case, I built the library .jar myself and had no idea why the VerifyError would appear when trying to test the .jar in a test application.
The problem was in proguard.cfg with -assumenosideeffects and Log.
Specifically, inside proguard.cfg (of my library) there was a following line:
-assumenosideeffects class android.util.Log {*;}
Replacing it with:
-assumenosideeffects class android.util.Log {
public static *** v(...);
public static *** d(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
}
and building and obfuscating it again resolved the problem.
I found the answer to my problem here.
I know this doesn't directly answer to the original question, but I left this answer here in order to help someone who is trying to build the .jar and the result of using it is VerifyError.

I had a similar error:
FATAL EXCEPTION: Connection#7864356
Process: ..., PID: 24458
java.lang.VerifyError: Verifier rejected class r8.a: r8.b r8.a.b(w8.a[]) failed to verify: r8.b r8.a.b(w8.a[]): [0x33] expected to be within a catch-all for an instruction where a monitor is held (declaration of 'r8.a' appears in /data/app/~~DIy9qxh1lGM...==/base.apk)
at p7.g$b.b(SourceFile:270)
at p7.g$b.run(SourceFile:35)
This happened after I updated gradle from 4.2.2 to 7.3.1. I tried disabling obfuscation and the #Keep option for the specified classes in the error message. But nothing helped. In debug mode, everything still worked, but in the release the app crashed with an error.
Thanks Dupinder Singh.
I've changed my top-level build.gradle file with:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools:r8:4.0.48'
classpath 'com.android.tools.build:gradle:7.3.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now everything works. Maybe my solution will help someone.

Related

com.android.tools.r8.CompilationFailedException:Compilation failed to complete, position:Lcom/facebook/login/DefaultAudience$EnumUnboxingLocalUtility;

I have some error, after updated kotlin version (ext.kotlin_version) to 1.6.10:
com.android.tools.r8.internal.E00: Unexpected type in conversion to primitive: OBJECT
Execution failed for task ':app:minifyReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: Lcom/facebook/login/DefaultAudience$EnumUnboxingLocalUtility;getNativeProtocolAudience(I)Ljava/lang/String;, origin: ..\.gradle\caches\transforms-3\57102c4e3d32396b86898e5ca0dd620d\transformed\jetified-facebook-core-7.1.0-runtime.jar:com/facebook/login/DefaultAudience.class
It happened, if I use options minifyEnabled true in my build.gradle(:app) with Generate signed bundle.
If I use old ext.kotlin_version (for examle, 1.5.0) this error did not appear.
I think, if I use correct rule(s) in proguard-rules.pro I could resolve this issue.
This was caused by an issue in R8. Fix is available in R8 3.1.71, 3.2.55 and 3.3.26-dev versions.
Add the following to settings.gradle or settings.gradle.kts to use a specific version of R8 different from the one bundeled with AGP:
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:X.Y.Z")
classpath('com.google.guava:guava:30.1.1-jre') // <-- THIS IS REQUIRED UNTIL R8 3.2.4-dev
}
}
}
I find right rule for decide this problem.
You need add this code into proguard-rules.pro:
-keep class com.facebook.login.** {*;}
This line let ignore option minifyEnabled true for all files into com.facebook.login package.

R8 Crashes Silently on Build

I get the following warning - error when building an Android release.
WARNING:R8: Unexpected error during rewriting of Kotlin metadata for class 'androidx.lifecycle.LifecycleController$observer$1':
com.android.tools.r8.internal.sG: lateinit property function has not been initialized
at com.android.tools.r8.internal.Xn.a(SourceFile:302)
at com.android.tools.r8.internal.Kn.a(SourceFile:49)
at com.android.tools.r8.internal.Kn.a(SourceFile:24)
at com.android.tools.r8.utils.V.a(SourceFile:36)
at com.android.tools.r8.utils.V.a(SourceFile:41)
at com.android.tools.r8.utils.V.a(SourceFile:35)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1448)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Usually I wouldn't have given much attention to a warning.
But we're experiencing a related lifecycle bug in release (like the observer doesn't work at all).
I've tried -keepclasseswithmembers class androidx.lifecycle.LifecycleController.** { *; } with no luck.
Applying the R8 plugin in my Project lvl gradle fix this issue for me:
buildscript {
repositories {
maven {
url 'https://storage.googleapis.com/r8-releases/raw'
}
}
dependencies {
classpath 'com.android.tools:r8:3.0.65' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
}
}

Is R8 not support applyMapping?

Use applyMapping will lead to a compile exception, like:
R8: 'boolean readField(int)' already has a mapping
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
My Android Gradle Plugin's version is 3.5.3, I find it's a question of R8. Because when disable R8, applyMapping work fine, enable the R8, it will not work.
I fond that the Mapping.txt generated by R8 has the duplicate methods like this:
1:1:boolean readField(int):0 -> a
2:2:boolean readField(int):0:0 -> a
If remove one of them, it will work fine.
You are using an older version of R8 that too eagerly reports error in the mapping file. Try to use an older version by adding the following to your top-level build.gradle file:
buildscript {
repositories {
maven {
url 'http://storage.googleapis.com/r8-releases/raw'
}
}
dependencies {
classpath 'com.android.tools:r8:1.6.60' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
}
}
This should help out with your issue.

Cannot find symbol DataBindingComponent on Android Studio 3.2 Canary 16 Kotlin project

I just created a new project on Android Studio 3.2 Canary 16 with Kotlin enabled. Then I also enabled data binding, but I'm getting an error saying that it could not find the DataBindingComponent class.
Here's my project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.41'
ext.android_plugin_version = '3.2.0-alpha10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha16'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My module gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "net.julianonunes.myapp"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.android.support:design:27.1.1'
kapt "com.android.databinding:compiler:3.1.2"
}
My activity's xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="data"
type="net.julianonunes.myapp.RegisterData" />
</data>
....
</layout>
And here's the build output:
Executing tasks: [clean, :app:assembleDebug]
Configuration on demand is an incubating feature.
> Configure project :app
app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'androidx.databinding:databinding-compiler:3.2.0-alpha16'.
> Task :clean
> Task :app:clean
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript
> Task :app:checkDebugManifest
> Task :app:generateDebugBuildConfig
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:mainApkListPersistenceDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:processDebugManifest
> Task :app:splitsDiscoveryTaskDebug
> Task :app:processDebugResources
> Task :app:generateDebugSources
> Task :app:dataBindingExportBuildInfoDebug
> Task :app:transformDataBindingBaseClassLogWithDataBindingMergeGenClassesForDebug
> Task :app:transformDataBindingWithDataBindingMergeArtifactsForDebug
> Task :app:dataBindingGenBaseClassesDebug
Download https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.1.2/compiler-3.1.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.1.2/compiler-3.1.2.jar
> Task :app:kaptGenerateStubsDebugKotlin
e: /home/juliano/Documents/Projetos/myapp/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/net/julianonunes/myapp/databinding/ActivityMainBinding.java:28: error: cannot find symbol
protected ActivityMainBinding(DataBindingComponent _bindingComponent, View _root,
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
e: /home/juliano/Documents/Projetos/myapp/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/net/julianonunes/myapp/databinding/ActivityMainBinding.java:46: error: cannot find symbol
#Nullable ViewGroup root, boolean attachToRoot, #Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
e: /home/juliano/Documents/Projetos/myapp/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/net/julianonunes/myapp/databinding/ActivityMainBinding.java:57: error: cannot find symbol
#Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
e: /home/juliano/Documents/Projetos/myapp/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/net/julianonunes/myapp/databinding/ActivityMainBinding.java:68: error: cannot find symbol
#Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
e: [kapt] An exception occurred: java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at android.databinding.annotationprocessor.ProcessExpressions.onHandleStep(ProcessExpressions.java:77)
at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.runStep(ProcessDataBinding.java:203)
at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.access$000(ProcessDataBinding.java:188)
at android.databinding.annotationprocessor.ProcessDataBinding.doProcess(ProcessDataBinding.java:90)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:65)
at org.jetbrains.kotlin.kapt3.ProcessorWrapper.process(annotationProcessing.kt:131)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:87)
at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:45)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:257)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:212)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:95)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:97)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:84)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:374)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:64)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:101)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:365)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:130)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:161)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:405)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:920)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:98)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:950)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:919)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:404)
at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
> Task :app:kaptDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Compilation error. See log for more details
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
20 actionable tasks: 19 executed, 1 up-to-date
What is wrong with my project?
PS: The problem also happens on Android Studio 3.1.2
Databinding libraries are being refactored as a part of androidx refactoring.
I found the databinding annotation processor dependency link from google's maven repository here.
I've constructed the actual gradle dependency from there.
kapt "androidx.databinding:databinding-compiler:3.2.0-alpha16"
Update
As of Android studio 3.2.0-beta01, databinding no longer needs its annotation processor dependency to be declared in the gradle file, since databinding is capable of resolving its dependency.
With the following setup
Android Studio 3.2.1 Build #AI-181.5540.7.32.5056338, built on October
8, 2018 JRE: 1.8.0_152-release-1136-b06 x86_64 JVM: OpenJDK 64-Bit
Server VM by JetBrains s.r.o macOS 10.13.3
And DataBinding simply enable by having this in my app build.gradle
apply plugin: 'kotlin-kapt'
and then
dataBinding {
enabled = true
}
and also this in my gradle.wrapper properties
android.databinding.enableV2=true
I had the same errors:
could not find the DataBindingComponent class.
I had more than 100 of them. It turned out that those errors were not important and that the true underlying error was not showed by the IDE. Therefore, I increased the number of errors that the Kotlin compiler can display by adding this in build.gradle:
dataBinding {
enabled = true
}
kapt {
javacOptions {
// Increase the max count of errors from annotation processors.
// Default is 100.
option("-Xmaxerrs", 500)
}
}
An suddenly, right below all those fake errrors, I saw the real one caused by a failed merge conflict resolution 😔
Just delete the compiler dependency (kapt "com.android.databinding:compiler:$gradleVersion), that worked for me. Apparently, it is provided with binding plugin from 3.2.0.
Same Error here on Android Studio 3.3.1, no Kotlin, pure Java, using androidx
build.gradle contains
dataBinding {
enabled true
}
gradle.properties contains
android.useAndroidX=true
android.enableJetifier=true
android.databinding.enableV2=true
I've been fighting the issue for hours and then solved it as follows:
Temporarily declare an empty interface for DataBindingComponent in your Project (in src/main/java/androidx.databinding/DataBindingComponent.java)
package androidx.databinding;
public interface DataBindingComponent {
}
Let it compile and the error will be gone. But now the actual root error will be revealed. The one that was actually causing all the trouble but was somehow swallowed. In my case it was coming from AutoValue indicating that i was using it incorrectly
error: Parameter type java.lang.Boolean of setter method should be boolean to match getter
fixing that and then removing the dummy interface makes the compiler happy again.
If You're already using Android Studio 3.2 stable version, Just remove the dependency, it's already included.
For what it’s worth, I had a similar issue and it was the result of a bad Room query that was related to a data binding.
In my case it was a bad dagger annotation. I put custom scope on a Module instead of putting it on a provides method.
¯\_(ツ)_/¯
I had the same issue.
Changing Kapt to annotationProcessor only for DataBinding fixed the problem for me.
i face this problem when updating to android studio 3.2 , i change gradle plugin from 3.2.0 to 3.1.4 and it works fine
--> i think it's a gradle problem , it will be updated for sure very soon
Dagger may also be the cause. Changing dagger version from 2.17 back to 2.16 can fix this problem for now.
Discussion: https://github.com/google/dagger/issues/1245
Update
Dagger 2.18 is out but unfortunately it still won't work after I tested(Have I missed something?).
Update2
Dagger 2.19 also won't work and the discussion is locked.
But in the google issuetracke, there're solutions/workarounds. I tested and they worked. Check it if you want to use the latest Dagger.
Update3
Dagger problem has been fixed in the Android Studio 3.3.
My issue was that I tried to enable data binding for my Login module but not the App module. After adding:
dataBinding {
enabled = true
}
to the App module and removed it from the Login module, it worked.
i finally fixed my problem because i was using Android Annotations and they released a new Version 4.5.1 1 Hour ago, where they support Grade Plugin 3.2.0.
I was searching for this bug for a week and i´m happy now. Hope this helps you, too!
In my case I enabled data binding in dynamic feature module only. After I enabled data binding in root module, error disappeared.
From documentation:
Note: You must configure data binding for app modules that depend on libraries that use data binding, even if the app module doesn't directly use data binding.
Also you may need to invalidate caches and restart.
I solved the error by adding
android.useAndroidX=true
android.enableJetifier=true
in my project's gradle.properties file
Just remove kapt "com.android.databinding..." dependency. If you are using Android Studio 3.2 or greater version.
In my case,
If your using Dynamic Feature Module :
build.gradle(app)
dataBinding {
enabled true
}
This needs to enabled on both root and child gradle files (don't forget to add kapt plugin).
I have tried classpath 'com.android.tools.build:gradle:3.2.0-beta05'
with and without explicit dependency kapt "androidx.databinding:databinding-compiler:3.3.0-alpha06"
And still getting the same exception.
I have also tried 3.3.0-alpha06 but nothing changed.
UPDATE:
After 2 days, I resolved the issue.
What I did is, manually fixing all the files that had problems, because of Migration to AndroidX (wrong packages in imports and XMLs etc.). Additionally, I needed to update Glide from 4.7 to 4.8. When I fixed all red files the problem disappeared.
This is my most stupid mistake!
I have actually created a private variable for Databinding and that was causing this issue.
Just use a lateinit var binding and it Worked.
This could help someone!
For me, there was an error in my layout file. I referenced a function that was non-existent.
android:text="#{() -> sleepTrackerViewModel.nightStrings}"
Below is the solution:
android:text="#{sleepTrackerViewModel.nightStrings}"
Please add this line in gradle.properties
android.enableJetifier=true
I fix it updating Android Studio to Canary 16 AND this in gradle.wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
In my case the issue was resolved by changing:
androidExtensions.experimental = true
(i.e. gradle DSL as a one-liner)
to
androidExtensions {
experimental = true
}
apart from could not find the DataBindingComponent class I also had error: incompatible types: NonExistentClass cannot be converted to Annotation associated with kotlinx.android.parcel.Parcelize annotation (#Parcelize)
Android Studio 3.3; gradle-4.10.1-all; tools.build:gradle 3.3.0
Had same issue when I was importing class in databinding, that did not exist. Also use
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}
for recieving all error messages to find the issue. For my project it was limited to 50.
Something else to try :) I was trying to get the GithubBrowserSample into Android Studio 3.2 (RC3). I kept getting lots of weird errors on databinding even though it doesn't specify data binding versions in the main build.gradle. The solution was to remove these two lines from the gradle.properties:
org.gradle.jvmargs=-Xmx4536m
android.databinding.enableV2=true
My situation:
Android Studio v3.2.1
com.android.tools.build:gradle:3.2.1
https://services.gradle.org/distributions/gradle-4.10.2-all.zip
I found that by removing databinding from my layout, recompiling the app and then adding the databinding back in it fixed this issue.
I changed the DataBindingUtil.setContentView(...) to just setContentView(...) and reduced my activity layout to the bare minimum:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"/>
</FrameLayout>
Then add the databinding back in piece by piece.
In my case there was an import error in one of the files. Simply opening that file made imports to happen automatically and thereafter project got built.
It's a pity, that AS gave zero indication to this, neither did error stacktrace.
In case nothing from posted answer helps - just surf through all the files in the project and seek for a file which has incorrect import statement.
It's a bug in jetifier. Here's a workaround for now until the next update. Put this in your project gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
}
}
If you are using dataroom library, check #Dao annotation in your DAO classes.
In my case, I forgot to add #Dao to my interface of RoomDatabase'Dao.
Build errors for generated interfaces like DataBindingComponent are usually misleading. Try to look for any other build errors and fix those first, then recompile.
I had to remove following import from Gradle,
androidx.room:room-compiler:2.1.0-alpha06
Even though its weird issue, Just try to remove to un necessary imports, it should work.

Error generating signed apk with android map utils library

Since I added this dependency I cannot generate a signed APK anymore. Weirdly, Build/Build APK works, but Build/Generate signed APK fails with these lines:
Warning:com.google.maps.android.clustering.ClusterManager: can't find superclass or interface com.google.android.gms.maps.GoogleMap$OnCameraIdleListener
Warning:com.google.maps.android.clustering.ClusterManager: can't find referenced class com.google.android.gms.maps.GoogleMap$OnCameraIdleListener
Warning:com.google.maps.android.kml.KmlRenderer: can't find referenced method 'void setZIndex(float)' in program class com.google.android.gms.maps.model.Marker
Warning:there were 4 unresolved references to classes or interfaces.
Warning:there were 1 unresolved references to program class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:java.lang.RuntimeException: java.io.IOException: Please correct the above warnings first.
Error:java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
Here is my module build.gradle dependency part:
apply plugin: 'com.android.model.library'
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.google.maps.android:android-maps-utils:0.4+'
}
model
{
[etc...]
}
And this is the project level one:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.8.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
it may be Proguard (which is doing its work) when you try to generate the signed apk(release version), you may solve this by adding
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
But normally this is already done in the maps library, i would recommend using the latest version the maps lib before You try the above solution
com.google.android.gms:play-services-maps:9.8.0

Categories

Resources