"MissingRegistered" Lint warnings when using com.google.android.material.* UI components - android

I'm trying to get rid of the Lint warnings in my Android project. Doing so I run into the following type of warning messages that I do not understand:
app\src\main\res\layout-land\event_settings_fragment.xml:25: Error: Class referenced in the layout file, com.google.android.material.textfield.TextInputLayout, was not found in the project or the libraries [MissingRegistered]
<com.google.android.material.textfield.TextInputLayout
^
My app seems to be running fine, so the com.google.android.material.textfield.TextInputLayout class should be available in the project?
Note that I do get this warning on all com.google.android.material.* classes.

MissingRegistered
Summary: Missing registered class
Priority: 8 / 10
Severity: Error
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable MissingRegistered
If a class is referenced in the manifest or in a layout file, it must also
exist in the project (or in one of the libraries included by the project. This
check helps uncover typos in registration names, or attempts to rename or move
classes without updating the manifest file properly.
See: http://tools.android.com/tips/lint-checks
If you ensure that the layout file runs without problems, you can disable the check:
app/build.gradle
android{
lintOptions{
disable "MissingRegistered"
}
}
or add tools:ignore="MissingRegistered" in the layout file to suppress the check.

Related

Android FirebasePerformance issue with Proguard

We implemented FirebasePerformance in our project and when are unable to build the project. I get below error in Proguard which has something to do with having a two classes with same name but different cases (A.class and a.class) in the external library (qrchart_obfuscation.jar). I am not very familiar with proguard also.
Reading thru sources, I am looking to add -dontwarn option in proguard but this will be my last resort since sources says to "use it only when you know what you are doing".
I still tried to add -dontwarn qr.android.chart and I compared Mapping.txt with my previous builds which does not have FirebasePerformance and I see a difference on the class (qr.android.chart) not sure if this detail helps
Appreciate your help and suggestions with proguard setup for FirebasePerformance.
Reading program directory [C:\...\build\intermediates\transforms\FirebasePerformancePlugin\adevelop\release\4] (filtered)
Warning: class [qr/android/chart/b/a.class] unexpectedly contains class [qr.android.chart.b.A]
Warning: class [qr/android/chart/b/b.class] unexpectedly contains class [qr.android.chart.b.B]
Warning: class [qr/android/chart/b/c.class] unexpectedly contains class [qr.android.chart.b.C]
Warning: class [qr/android/chart/b/d.class] unexpectedly contains class [qr.android.chart.b.D]
Warning: class [qr/android/chart/b/e.class] unexpectedly contains class [qr.android.chart.b.E]
Warning: class [qr/android/chart/b/f.class] unexpectedly contains class [qr.android.chart.b.F]
Warning: class [qr/android/chart/b/g.class] unexpectedly contains class [qr.android.chart.b.G]
Warning: class [qr/android/chart/b/h.class] unexpectedly contains class [qr.android.chart.b.H]
Warning: class [qr/android/chart/b/i.class] unexpectedly contains class [qr.android.chart.b.I]
Warning: class [qr/android/chart/b/j.class] unexpectedly contains class [qr.android.chart.b.J]
Warning: class [qr/android/chart/b/k.class] unexpectedly contains class [qr.android.chart.b.K]
Warning: there were 11 classes in incorrectly named files.
You should make sure all file names correspond to their class names.
The directory hierarchies must correspond to the package hierarchies.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
If you don't mind the mentioned classes not being written out,
you could try your luck using the '-ignorewarnings' option.
I saw this link with regards to Firebase performance and proguard issue during build of signed APK but different case -FirebasePerformance SDK external library issue in progaurd
The problem is the qr.android.chart library isn't using the dontusemixedcaseclassnames option when proguarding.
When building on a case insensitive file system (i.e., that Mac OSX likes to use), the byte code instrumentation process Firebase Performance uses runs into issues because the unarchived classes end up overwriting each other.
Your options are to either disable byte code instrumentation or ask for a new qr.android.chart library with the dontusemixedcaseclassnames option activated.
If you are working on macOS, I've found an ugly workaround for this. Create a case sensitive disk image and copy the project there, so firebase perf plugin can handle the case sensitive files.
How to create the disk image here: https://documentation.spryker.com/tutorials/howtos/ht-case-sensitive-file-system-mac.htm
For my project I needed a 5gb image.

android data binding: how to get useful error messages

In android studio 2.1, the compile time error messages from xml mistakes are entirely non-helpful:
Error:(11, 41) error: package mypackage.databinding does not exist
Error:(15, 13) error: cannot find symbol class MyActivityBinding
The real error would usually be something like "there's no such attribute android:adapter", or "variable foo doesn't contain property bar" or something like that. But instead of actually showing such errors, it shows the above unhelpful ones, which only tell you that the bindings weren't generated because of some unknown error.
The way I use in Android Studio 4.0:
Select the top level Build: failed item on the Build Output panel
On the right part click Run with --stacktrace. When build is finished select the top Build: failed item again on the left panel. You'll get a databinding error description on the right panel:
In my case it's:
[databinding] {"msg":"Cannot find a getter for \u003ccom.google.android.material.slider.Slider app:value\u003e that accepts parameter type \u0027java.lang.Float\u0027\n\nIf a binding adapter provides the getter, check that the adapter is annotated correctly and that the parameter type matches.","file":"SliderDatabinding\src\main\res\layout\activity_main.xml","pos":[{"line0":14,"col0":8,"line1":21,"col1":41}]}
Clink on Toogle View, under the 'Build' icon will give you details logs
There's no easy way for now. In general, if you face such compilation error and error messages point at missing databinding classes it is usually either bad reference from layout (i.e. you try to access members classes you assigned do not expose - usually happens when you c&p layouts).
Even worse, when you use other code generating libraries (Icepick, Butterknife, etc) then the real culprit can be often in code completely unrelated to binding. So when something like this occur in my code, I usually check Gradle Console view and read it from the end up, ignoring all error messages related to databinding like "missing class" or "package does not exists"
One way of getting the proper error is to run gradle in a terminal with '--info', like:
gradle :app:build --info
That's not exactly integrated into AS, so I can't really accept that answer.

android:targetPackage cannot resolve symbol

this might seem trivial but I can't understand why I'm getting this error.
I downloaded the sample app activityInstrumentation( from Android Studio File -> import Sample) and inside the testing project manifest I get an unresolved symbol for
android:targetPackage="com.example.android.activityinstrumentation".
After that I've created a manifest for my application and still there is an unresolved symbol on the attribute.
My application project dir and test project dir are:
app/src/main/java/com/example/appname
where manifest has
package="com.example.appname"
app/src/androidTest/java/com/example/appname
where manifest has
<manifest
...
package="com.example.appname.tests"
...
android:targetPackage="com.example.appname"
...
</manifest>
Please help me sort this out. I don't know what else I can do: using a sample app to create a full fledged test project was my very last hope.
You must specify android:targetPackage in instrumentation tag.
[http://developer.android.com/guide/topics/manifest/instrumentation-element.html
]
I see the same thing. Seems to be only false alert produced by the lint code inspection. When you run analysis (Analyze->Inspect code...) and open "Inspection" tab you can select the warning and mark it Suppress for tag. That will get rid of the warning.

"trouble writing output: Too many field references: 70185; max is 65536. You may try using --multi-dex option." when building Android project

I hit this error and found no hits for the error message, so I thought I'd share the solution I came up with to save anyone else facing the problem repeating my work.
When writing a new Android library (apklib) for use in a (large) application, I'm getting the following error during dexing when I add my new project as a dependency:
trouble writing output: Too many field references: 70185; max is 65536.
You may try using --multi-dex option.
References by package:
<...long list of packages with field counts elided...>
The particular build step it fails on is:
java -jar $ANDROID_SDK/build-tools/19.0.3/lib/dx.jar --dex \
--output=$PROJECT_HOME/target/classes.dex \
<... long list of apklib and jar dependencies elided ...>
Using --multi-dex as recommended by the error message might be a solution, but I'm not the owner of the application project and it already has a large complex build process that I would hesitate to change regardless.
I can reproduce this problem with a no-op test library project that has literally no fields, but in the error output it's listed as having 6000+ fields. Of the packages listed in the error output, there are a handful with similar 6k+ field counts, but then the vast majority have more plausible <1k field counts.
This problem is similar to the "Too many methods" problem that Facebook famously hacked their way around. The FB solution seems insane, and the only other solutions I've found (e.g., this Android bug ticket, or this one, this SO answer, this other SO answer) all involve changing the main app's code which is well beyond the scope of what I want to do.
Is there any other solution?
The solution was to change the package in the AndroidManifest to match the main application's package.
A manifest like this:
<manifest package="com.example.testlibrary" ...
resulted in 6k+ fields and build failure. Changing it to match the main application's package
<manifest package="com.example.mainapplication" ...
resulted in the project building successfully.
Note that only the package in the manifest is changing, I did not make any changes to the library's Java source or its layout (the Java package was still com.example.testlibrary with directory structure to match).
I hypothesize that the different package name is causing all the Android fields to be included again under that package. All the packages in the error listing with 6k+ fields had a different package name than the main application.
I also (later, grr), found this blog post which details the same problem and the eventual same solution.

java.lang.ClassNotFoundException on working app

I have created and published my first Android app. It's very simple. It works fine on simulator and some phones, but I am getting this error:
java.lang.RuntimeException: Unable to instantiate application cz.teamnovak.droid.Novak ESC Track guide: java.lang.ClassNotFoundException: cz.teamnovak.droid.Novak ESC Track guide in loader dalvik.system.PathClassLoader[/data/app/cz.teamnovak.droid-1.apk]
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)
at android.app.ActivityThread.access$3000(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: cz.teamnovak.droid.Novak ESC Track guide in loader dalvik.system.PathClassLoader[/data/app/cz.teamnovak.droid-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.Instrumentation.newApplication(Instrumentation.java:942)
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644)
... 11 more
Any idea what can cause this?
Yep, I had this exact same problem. It was because I specified the android:name attribute in the application node in the manifest file.
Your Android Manifest file probably looks something like this:
<application
android:name="Novak ESC Track guide"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
Do not use the android:name attribute! unless you've implemented a custom Application object.
The application:name attribute has nothing to do with the name of your app. This is the name of a specific class to load as your Application instance. That's why you would get the ClassNotFoundException if that class wouldn't exist.
For the name of the app use the android:label attribute on this same application node instead.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
Something like this happened when I changed the build target to 3.2. After digging around I found that a had named the jar lib folder "lib" instead of "libs". I just renamed it to libs and updated the references on the Java build path and everything was working again. Maybe this will help someone...
We have a couple of projects where this issue was logged from time to time on the Android Market. I found the following issues in the manifests:
If the package name is com.test then activities names should be .ActivityName (with a leading dot), not just ActivityName.
For some classes, those that appeared in the logs most often, the class name was specified as com.test.Name while it should have been .Name.
I guess many implementations of Android handle these minor issues successfully (this is why the exception never happened in testing), while others few are throwing the exception.
I have this problem sometimes with eclipse. What has corrected it for me is to go to Project Properties / Android and change the build target API to a different version and republish. I'll find that corrected it, then I can change it back to the desired build target.
or
You may need to check your proguard.cfg.
Assuming you have linked your libraries properly and that your library projects have the code you need marked for export, the next step you might want to do is to check your proguard settings and make sure you are not stripping out the classes you need.
I was struggling with this quite a bit after I had my app working going directly to the emulator or device from eclipse. The problem I was having was after the app was published (i.e. gone through proguard) and run on the device it was missing classes that were contained in the project. They were being stripped out somehow.
My problem may have been caused when I had tried to use IntelliJ and have switched back to eclipse.
Here is the proguard file that worked for me:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembers class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Had the same error: java.lang.RuntimeException: Unable to instantiate activity (classnotfound)
FIRST try to change the build platform (2.3.3 -> 2.2 -> 2.3.3) worked for me.
This is my observation with respect to the Error. I recently Updated the ADT to 22.0.1.
I am getting following Error when i imported my previous Projects
"E/AndroidRuntime(24807): Caused by: java.lang.ClassNotFoundException: com.sherl.sherlockfragmentsapp.StartActivity in loader dalvik.system.PathClassLoader[/data/app/com.sherl.sherlockfragmentsapp-1.apk]"
Then I changed "Properties->Java Build Path-> Order and Export" in the following manner
[Unable to add the Image because of the Forum rules]
Android Private Libraries - checked
Android 4.2.2 - unchecked
Android Dependencies - checked
/src - selected
/gen - selected
It resolved the issue. Hope this is Help you guys.
I know this question has been answered, and it likely wasn't the case. But I was getting this error, and figured I'd post why in case it can be helpful to anyone else.
So I was getting this error, and after several hours sheepishly realized that I had unchecked 'Project > Build Automatically'. So although I had no compilation errors, this is why I was getting this error. Everything started working as soon as I realized that I wasn't actually building the project before deploying :-/
Well, that's my story :-)
Had this sort of problem today after upgrading to latest ADT/SDK. Took me quite a while. Checked that i used google-apis (for maps), uses-library, cleaned the project etc.
Deleting the .project and adding a fresh one (create new android project) finally solved it.
I got this error when I ran my app on earlier versions of android. I thought SearchView was backwards compatible to Android 1.5, but it was created in 3.0. I removed its reference from the code and it worked.
In my case I had to add android:name=".activity.SkeletonAppActivity"
instead of android:name=".SkeletonAppActivity" in the manifest file for the main activity.
SkeletonAppActivity was in a different package from the application class. Good luck!
Make sure that android:hasCode is not set to false in your manifest file. This is what solved the problem for me!
Well you have a java.lang.ClassNotFoundException. That means a class is missing in the application runtime. You should check wheather you have added all your libs to the build path.
Right click on your project -> properties -> java build path -> libraries, add your libs or create one containing your classes and enable order export for your libs.
In my case, the icon of the app was causing the error:
<application
android:name="com.test.MyApp"
android:icon="#drawable/myicon"
Why? Because I put the icon only in the folder "drawable", and I'm using a high resolution testing device, so it looks in the folder "drawable-hdpi" for the icon. The default behaviour for everything else is use the icons from "drawable" if they aren't in "drawable-hdpi". But for the launching icon this doesn't seem to be valid.
So the solution is to put a copy of the icon (with the same name, of course) in "drawable-hdpi" (or whichever supported resolutions the devices have).
I used a supertype method that was declared 'final' in one of my Activities (specifically the 'isResumed()' method). The actual error showed in LogCat only after restarting my development device.
The Class Not Found Error shows that your class files are missing. Please go to Properties > Java Build Path and add your package containing your java files to the Source tab if found missing. Then build your project. This will create the missing .class files.
I recently invested some time in a similar error report that reached me through the play store error reports.
An overview of some possible causes.
Missing Library
Since my app is tested before release and the issue only occurs approx. once a week I'm pretty sure mine isn’t a library issue. You should think in this direction if a build on your system fails and installing the app using ADB results in error on launch.
Cleaning and building your project could help if this is a local issue and make sure you have the latest version of both SDK and IDE.
In these cases it’s one class of your app or a library used in your app that triggers the error. This is an important difference with the next point where the entry point (Activity with MAIN intent or your custom service/Application object) of your app is not found.
If so look into the following questions & answers I’ve selected. They all have an accepted answer.
unable to instantiate application - ClassNotFoundException
Android Activity ClassNotFoundException - tried everything
Android ClassNotFoundException
Main Activity or Application not found
Misconfiguration of AndroidManifest.xml
More like a beginners mistake was quoted here before in one of the answers talking about the android manifest file.
Important here is that this error would always block your app from loading. It should build though but crash on the first use.
I’ve edited that answer, this is the important part:
Do not use the android:name attribute! unless you've implemented a
custom Application object.
The application:name attribute has nothing to do with the name of your
app. This is the name of a specific class to load as your Application
instance. That's why you would get the ClassNotFoundException if that
class wouldn't exist.
For the name of the app use the android:label attribute on this same
application node instead.
Suppressed: java.io.IOException: unable to open DEX file
Now it’s getting interesting! This was part of the stack trace logged in my case through the playstore. So I can create a build and execute that on my device without errors (whereas all previous errors would prevent any run).
An important comment was made to the following SO question Android Application ClassNotFoundException, Unable to instantiate application
Looks like the system has trouble opening your application dex file java.io.IOException: unable to open DEX file, this is before any of your classes are loaded, so it doesn't have anything to do with how you define your application class in the Manifest. – user2046264 Feb 27 '14 at 2:25
The important part here is the suppressed IOException. This indicates that an IO operation failed. Examples of IO operations are network and storage calls.
Another error report that goes into that direction is listed at Android to Unable to instantiate Application java.lang.ClassNotFoundException: where the role of the external storage provided by an sdcard is mentioned.
Some other similar questions indicate that this can be a user error. "/mnt/asec/..." indicates that the app is running from the sdcard. If the sdcard is removed it could cause this error. 3rd party apps or rooted devices can probably move an app to the sdcard even if its not allowed by the manifest.
If you’re desperate read all the answers to that question since there are some other paths listed also. Think of full package specification, use of singletons and more.
The point here is that both network and storage are IO.
For my specific case I checked all the devices that reported this error and found that they all have external storage support. So a user could install the app and move it to external storage, have the SD card removed and get this error (just a theory, not tested).
For more info on the installLocation options see http://developer.android.com/guide/topics/data/install-location.html
I also considered the network. On top of the stack trace detail page at the play store reports you get an overview of the occurrences of the error over time.
It appeared to me that the error occurred more around the times an update was released. This could support the theory that the user gets an update of the app, downloads this update that somehow gets corrupted. The installation goes fine but the first execution of the app results in the error (again just a theory, not tested).
Other resources
Finally 2 non SO resources that might help you:
https://groups.google.com/forum/#!topic/android-developers/JC7_qqwBRjo
https://code.google.com/p/android/issues/detail?id=72121
Are you using your code in different enviroments, let's say, by using Dropbox or something like that? Do you use any library or similar? I had a lot of troubles after sharing the workspace files and I fixed it reconfiguring dependences. Hope it helps somebody!
Check if the package name in the class matches the package name in the manifest file. This worked for me
In my case it happen when i moved my launcher activity to different package without updating manifest file.
I had a ClassNotFoundException pointing to my Application class.
I found that I missed Java builder in my .project
If something is missing in your buildSpec, close Eclipse, make sure everything is in place and start Eclipse again
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
I have same problem in android os version 4.1.2
add below line to your AndroidManifest.xml below android:label="#string/app_name" in application tag
android:name="android.support.multidex.MultiDexApplication"
This may help some one with same problem.
Setting minifyEnabled to false in my build.gradle file fixed the issue for me.
release {
minifyEnabled false
}
For me it was just to clean project.
I cleaned project, and run again. And all errors gone.
What helped me in case of Android Studio:
The problem occurred after renamning package of large project.
So I did almost everything AS offers to clean and refresh the project officially, and it works. I'm not saying this is solution for everyone just in case you're using Android Studio. Done in Android Studio 3.5.1, Windows 10.
Alex's answer
Build > Clean Project
Build > Rebuild Project
File > Sync with File System
File > Sync project with Gradle Files
File > Invalidate Caches / Restart
Make sure that you have package
com.aaraf.demowithdoc //Your Package Name
com.aaraf.demowithdoc [YOUR PACKAGE NAME]
is there in your class where this java.lang.classnotfoundexception is occuring
For me, 'closing' the application from Eclipse and 'reopening' of the project, resolved the issue.

Categories

Resources