When running Android Studio/ Analyze/ Inspect Code...
I get 50+ identical error messages "Android/Lint/Correctness Error
Upgrade Fragment version to at least 1.3.0" on this line of code:
class MainActivity : AppCompatActivity() {...
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->...
The code breaks on breakpoints, so code is called and the application works correctly.
Build gradle includes (Kotlin language)
implementation "androidx.activity:activity-ktx:1.2.1"
implementation "androidx.fragment:fragment-ktx:1.3.1"
debugImplementation "androidx.fragment:fragment-testing:1.3.1"
I want to FIX the error message (not hide it). Since the code works correctly, and I use fragment-ktx:1.3.1 what should I be looking for?
This has been reported on Google's Issue Tracker and, I quote:
This has been fixed internally and will be available in the next Activity release.
Source: https://issuetracker.google.com/issues/182388985#comment9
I have an app I created using Flutter / Dart / VSCode / Android Studio and wanted to work on it with Visual Studio App Center.
I add an Android app using Java / Kotlin, then add
dependencies { def appCenterSdkVersion = '3.2.2' implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}" implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}" }
to app/build.gradle but that's about as far as I get before messing up.
I don't know what 'my app's main class activity' is, I'm guessing it's not main.dart as when I put the following code in there I get errors.
import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.analytics.Analytics;
import com.microsoft.appcenter.crashes.Crashes;
I also can't find onCreate anywhere (other than AndroidManifest.xml where it's commented out).
I've looked through Getting started with the Android SDK, but can't figure it out.
Can anyone help me out?
I'm pretty much at the end of my tether so any help would be greatly appreciated!
UPDATE
build.gradle
dependencies {
def appCenterSdkVersion = '3.2.2'
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
}
MainActivity.kt
import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.analytics.Analytics;
import com.microsoft.appcenter.crashes.Crashes;
AndroidManifest.xml
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
AppCenter.start(getApplication(), "{My App Secret}",
Analytics.class, Crashes.class);
If you want to catch the crashes from Flutter there might be bit tricky for you because technically you'll have 4 types of crashes.
Android native crash.
iOS Native crash.
Dart crash
Flutter/Dart errors (i know they are not actual crashes but might mess up the app).
Now for point 1, if you want to add AppCenter you can add the code in the onCreate method of the FlutterApplication. You can find it your project -> android -> app -> src -> main -> expand packages
For iOS Native crash you will have to do it in AppDelegate, which is in your project -> iOS -> Runner -> AppDelegate.
For Dart/Flutter crash errors, I don't think there is support from AppCenter. I personally use Sentry and it's doing a pretty good job.
I am trying to customize the firebase in-app-messaging-display's UI of "Image Only" and "Modal" mode. So I turned to the official documentation, but it is quite simple, by saying:
Creating your own display is a two step process:
1.Write your own implementation of the FirebaseInAppMessagingDisplay class.
2.Register that implemenation with the headless Firebase In-App Messaging SDK.
I wonder how can I import in-app-messaging-display's source code into my project and make it work as a library.
I have downloaded its source code from github:https://github.com/firebase/firebase-android-sdk/tree/master/firebase-inappmessaging-display, tried to import it as a module, but after I selected the Source directory, Android Studio hints that: Specify location of the Gradle
or Android Eclipse project. I also have tried to copy the source code into my project's libs directory and added this: include ':libs:firebase-inappmessaging-display' into my settings.gradle file and this: implementation project(':libs:firebase-inappmessaging-display') into my app's gradle dependency. When sync building Android Studio reports errors like this:
ERROR: Unable to resolve dependency for ':XXXXXXXX': Could not resolve project :libs:firebase-inappmessaging-display.
Any suggestion will be highly appreciated.
The information on the doc is little bit confusing. I am also stuck with the same problem for long time. Actually its very simple.
Add these dependencies in your app level gradle file.
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation ("com.google.firebase:firebase-inappmessaging:17.0.3")
Register Your DisplayMessage component on starting activity.
import com.google.firebase.inappmessaging.FirebaseInAppMessaging
import com.google.firebase.inappmessaging.FirebaseInAppMessagingDisplay
///////
override fun onStart() {
super.onStart()
Log.e("MESSAGE", "activity started")
var firebaseInAppMessagingDisplay = FirebaseInAppMessagingDisplay { inAppMessage, cb ->
// You can show the message here.
// The variable inAppMessage has all information about the campaign that we putting in console (title, content, image url.. etc)
Log.e("MESSAGE", "Display Message callback invoked")
}
FirebaseInAppMessaging.getInstance().setMessageDisplayComponent(firebaseInAppMessagingDisplay)
}
I'm trying to use data-binding with Android.
I can not anymore build my project. I got this error :
"Error:(13, 46) error: package ch.company.project.databinding does not
exist"
Here my gradle :
http://pastebin.com/dkXd1Mxr
and
http://pastebin.com/n9hkFWGQ
And here the gradle output :
https://pastebin.com/w93Rausg
Thanks to Yigit!
The issue was not directly link to Android Databinding.
There were a bug in the project (some variables not correctly setted)
I would recommend to use gradle with "--debug and --stacktrace" for more informations, it's helping a lot.
earlier my package name was "com.xyz.abc.Models"
changing the package name to all small letters "Models" -> "models"
solved the issue.
The bug is not the DataBinding Package, it's a syntactic or logical error. For example, you have the attribute "lastName" in your POJO, but in the layout it's android:text="#{user.lastname}".
Check your "layout" and do Rebuild Project.
I am not satisfied with accepted answer, that tell you to stack trace without hints.
Here are some possible causes that lead to this problem. Check if you are not doing any of the following.
Basically Android DataBinding is not that mature still. It will fail without appropriate errors many times.
So if you have an issue like package ch.company.project.databinding does not exist".
Possible causes of fail:
First of all check your recently edited layouts xml one by one for errors (for wrong imports & variables). I don't get proper error in this case usually.
Check your data binding syntax in binding block ({...}) in layout element for errors. Always Rebuild (not Build) project after working in one layout.
Check your #BindingAdapter method having correct parameters. For example imageUrl binding adapter would accept ImageView or View as first parameter.
You should always Rebuild project after doing work in one layout.
If you are not able to find errors by above steps, then try --debug and --stacktrace in compile option of
File> Settings> Build, Execution, Deployment> Compiler> Command-line Options
Make sure your package name start with lowercase letter.
in my case issue solved after two hours of struggle
Package name should start with small letter.
for example Activities is wrong it'll give an error instead refactor->rename to activities
I got the error:
Error:(9, 46) error: package com.company.www.bar.databinding does not
exist.
i just remove "=" sign . it worked for me
From this :
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="#={()->activity.onButtonClick()}"/>
to :
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="#{()->activity.onButtonClick()}"/>
I had similar problems with my project
You could try:
check xml files for errors that cause a build failure
clean project
File -- invalidate caches / restart
On my particular case, I was using Dagger 2. This package error appears in a lot of classes without any relation with the original error: a dependency injection error.
Happy reminder: Scroll more on your stacktrace to know what is the real problem.
I was stuck with same error for hours. After trying several solution from stackoverflow, I updated my project with stable gradle dependencies.
Still it was not solved, however with the same gradle dependency DataBinding was working fine in another project of mine.
So, I went project folder using explorer and Deleted 2 things.
build folder
all files from .idea/libraries
After that i synced the project and it continued to work just fine.
Package names have to START with Small Letters. Otherwise, Binding library cannot understand that is it class or package. Moreover, you do NOT need to do all of it with small letters.
Example, wrong usage:
package com.thecompany.activity.ContactInfo; //Problem is ContactInfo, 'C'.
Example, TRUE usage:
package com.thecompany.activity.contactInfo; //Solution is contactInfo, 'c'.
Make sure your model's fields you reference in layout have public access modifiers
Change
{ databinding = true}
to
buildFeatures{
dataBinding = true
}
If you're coming to this question because you switched to JDK11 in Android Studio Artic Fox and your view binding broke in the UI but not during execution then be aware that this is a known issue and should be resolved in Bumble Bee:
https://issuetracker.google.com/issues/180946610
The current fix is to switch back to JDK8 (or install the Bumble Bee canary release).
To get rid of this error just enclose your complete layout design inside a plain layout tag in the activity_main.xml file.
After wasting many hours in finding solution this worked for me. Give it a try.
if you tried this steps
invalidate/restart`
keeping this properties in gradel.properties
android.databinding.enableV2=false
android.enableExperimentalFeatureDatabinding=true
and checking all xml files looks good.
then you should go with this solution, add below code in project level build.gradle
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}
this will give you exact error where you have actual error
explanation: above code will increase the size of the compile error
in my case, i follow the android documentation :
buildFeatures {
viewBinding true
}
use "=" instead of space
buildFeatures {
viewBinding = true
}
Try following Refactor -> migrate to androidx
and in the build.grade(:app)
implementation 'androidx.appcompat:appcompat:1.0.0'
or use new version is released
implementation 'androidx.databinding:databinding-runtime:4.1.0'
Make sure that if your layout filename is named in the following format: <name>_activity.xml that your binding class name complies the following format as well: <name>ActivityBinding
For me, changing my layout filename from activity_login.xml to login_activity.xml resolved this issue because my binding class name was LoginActivityBinding.
Here's an except from the Android Layouts and binding expressions page mentioning this:
A binding class is generated for each layout file. By default, the name of the class is based on the name of the layout file, converting it to Pascal case and adding the Binding suffix to it. The above layout filename is activity_main.xml so the corresponding generated class is ActivityMainBinding
if you use a model in your layout, make sure you dont have the model and the package named same and also the paackage name should start with small letter.
i changed mine from Model>Model.class to modelPac>Model.class
In my case the problem appeared when I was creating productFlavors and set sourceSets.
Changing
sourceSets {
develop {
res.srcDirs = ['myApp/src/develop/res']
}
to
sourceSets {
develop {
res.srcDirs = ['src/develop/res']
}
}
solved my issue.
for reporting my Application Crashes use Acra library via Android Studio Gradle Dependencies in this form :
dependencies {
compile 'ch.acra:acra:4.6.2'
}
Now in Bebug version it work and return crash report goodly but after export Release version of application not work and return this error in logcat :
Not adding buildConfig to log. Class Not found : " + className + ". Please configure 'buildConfigClass' in your ACRA config
Then i use acra-4-6-2.jar file instead dependencies but not work still!
Too before saw this link but was not helpful fore me.
With thanks for your attention
It sounds like you are Proguardng your app on release but have not added the relevant ACRA classes to your Proguard config.
See https://github.com/ACRA/acra/wiki/ProGuard
None of the other answers actually provided the fix.
To fix this issue, assign your BuildConfig.class to the buildConfigClass field on your ReportsCrashes annotation declaration.
#ReportsCrashes(
buildConfigClass = BuildConfig.class )
public class YourApplication extends Application { ... }
If you are using so called "dynamic" configuration you are probably having "empty" annotation like #ReportsCrashes().
In that case it turns out that ACRA does not create proper default config. The solution is simple: just add some fake property there like:
#ReportsCrashes(formUri = "placeholder")
which you will later override in the dynamic config...