Lint check "RemoveWorkManagerInitializer" fails, how to fix that? - android

My App class implements Configuration.Provider.getWorkManagerConfiguration, and regarding this article: https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration#on-demand
I switched default initializer with this string in my AndroidManifest.xml:
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
tools:node="remove" />
The code works as I need - no default initializer calls, but the only Configuration.Provider.getWorkManagerConfiguration.
If I run lint check I still see the error: Remove androidx.work.impl.WorkManagerInitializer when using on-deman initialization.
Android studio 4.1 beta 5
Gradle plugin: 4.1.0-beta05
Work manager: 2.3.4
Any thoughts on how to deal with it?

Related

GooglePlayServicesIncorrectManifestValueException when checking if play services are available

We are using GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) to check for google services before showing a map. Even though the device has access to play services, the method is throwing an exception when being called. The exception is GooglePlayServicesIncorrectManifestValueException with the message:
“The meta-data tag in your app's AndroidManifest.xml does not have the right value.
Expected 12451000 but found 4323000. You must have the following declaration within the
<application> element:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />”
In the manifest I’ve declared:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
If I go into the play services version, I get:
<integer name="google_play_services_version">12451000</integer>
Which comes from
jetified-play-services-basement-18.1.0/res/values/values.xml
I’ve tried most solutions in other stack overflow posts to no avail. These are all the things I’ve tried and none of them work:
Change tag order in manifest (https://stackoverflow.com/a/37810158/8575762). This has no effect, and also it makes no sense that it should have one.
Make sure we are not providing our own hardcoded version (https://stackoverflow.com/a/63791222/8575762)
Remove the <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" /> tag from the manifest.
Update firebase libraries to latest BOM version (30.5.0)
Remove firebase libraries completely.
Update play services dependencies to latest version(auth, auth-api-phone, vision, wallet, location, safetynet)
Update google services plugin to latest version (4.3.13)
Add tools:node="replace" (also tried other manifest options like node:replace, etc) to the metadata tag & hardcode the version value
If I inspect the AndroidManifest on the built apk (debug), the value of the meta-data tag is the following:
<meta-data
android:name="com.google.android.gms.version"
android:value="#ref/0x7f0b000f" />”.
It’s important to note that this behavior is not 100% consistent. Usually I’ll do a fresh install and the first time I launch the app the isGooglePlayServicesAvailable method returns without crashing. If I restart the app it no longer works.
This seems like a bug in the services implementation library to me, but it feels like something too simple to be failing like that.
Any help would be appreciated, thanks in advance.

AndroidManifest.xml merger failing, cached intermediate file Visual Studio Xamarin Forms Android

Strange problem with Manifest Merger, Visual Studio Mac, Xamarin Forms (5.0.0.2125), Android project, SDK 29 to 30. Problem initiated from an extra ">" in the Properties/AndroidManifest.xml file. That generated the error below, indicating the xml structure wasn't closed; line 35, column 11 being was the last line and character of the Properties/AndroidManifest.xml.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error AMM0000: Error: org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 11; XML document structures must start and end within the same entity. (AMM0000)
So, I edited out the extra character, and the obj/debug/AndroidManifest.xml is created and looks right, however, the build error remains the same!
Subsequent complete rewrites and edits of the Properties/AndroidManifest.xml file have only 2 outcomes
Entering an erroneous xml format will generate the appropriate errors describing the error.
Entering a correct xml format, with any combination of entries, lines and characters will generate a correct obj/debug/AndroidManifest.xml file with the the correct Properties/AndroidManifest.xml content. However, the original build errors stay, with the " line 35, column 11 being was the last line and character of the Properties/AndroidManifest.xml." error.
So, something cached, somewhere, but no clue where. Started during an aborted simulator build and has been here ever since.
Have tried quite few things including:
cleaning, rebuilding and many combinations
remove obj and bin
removing/adding declarations in the AndroidManifest.xml
using different AndroidManifest.xml files
deleting AndroidManifest.xml and running
restoring from cloud a different version of solutions
commenting out Activity declaration on MainActivity
reinstall of VS for Mac
I think it is similar to this bug
Xamarin android Manifest being replaced on build. only solution seems to be to repair visual studio
Has anyone seen this type of bug before?
Help much appreciated as have run out of ideas here.
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="17" android:versionName="1.17" package="com.mycompany.myapp">
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="30" />
<application android:label="myapp" android:icon="#mipmap/ic_launcher" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Solved here, github.com/xamarin/xamarin-android/issues/6385. Was a problem in a Nuget Firebase library AndroidManifest.xml file. Unfortunately the error reporting in VS Mac Manifest merging doesn't report which of the 140+ AndroidManifest.xml files has the problem. However, with a bit of sleuthing, there is a way to eventually work it out.

Android Play Store Error -505

When uploading an APK to the Android Developer Console, everything goes normal, but there are a certain subset of users on android 5.0 and up that are unable to install or upgrade the APK. These users see a Google Play Store error 505.
There are several different resources that tell you that the 505 error is a conflict of permission. Starting in Android Lollipop, you are no longer able to have duplicate custom permissions with the same name https://developer.android.com/about/versions/android-5.0-changes.html#custom_permissions. If you check stackoverflow for this error you'll find multiple reports of people offering this as a solution. While this can sometimes be the cause of this error there are several other reasons that this, and other conflicts can happen.
1. More than one app defines the same permission
If two completely different apps define the same permission e.g if you have a user and a manager app, and both of them have something along the lines of:
<permission
android:name="same.package.name.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
2. Same app signed by different keys
You have the same app, but signed by different keys. For example if you had a release version and a debug version, you'll hit a conflict because the system sees this as two different apps requesting the same permission.
3. Conflicting authorities
But there is an entirely different situation that can occur, which is less obvious. The 505 error can also occur with conflicting authorities. If two different apps declare the same provider, such as
<provider
android:name=".provider.YourProvider"
android:authorities="com.roqbot.client.YourProvider"
android:exported="false" />
This can also provide a conflict.
The last, and hardest conflict to spot, is one that can happen with Google Play Services 8.1 and up. If you do not define an application id in your build.gradle file like this:
defaultConfig {
applicationId "com.example.my.app"
}
it is possible that it will auto-generate a provider that can conflict with other apps. To check this, go into your your build>intermediates>manifests>full>release>AndroidManifest.xml and look for
<provider
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:authorities="com.google.android.gms.google_measurement_service"
android:exported="false" />
Here the authority name will conflict with other apps. If you add the applicationId to the default config, it will change this authority to
<provider
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:authorities="com.example.my.app.google_measurement_service"
android:exported="false" />
This is very subtle and appears to be a bug starting in google play services 8.1. The issue can be seen discussed here. https://code.google.com/p/android/issues/detail?id=189079&can=1&q=error%20505&sort=-opened&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened
The point to remember is that it may be several things, and the only thing you can verify for sure with a 505 error is that there is a conflict of some sort, and that it may or may not necessarily be a custom permission conflict.
If you are using the Facebook SDK and following the official sample code, you might also encounter the issue. In my case, I was using a same content provider name on 2 different app's manifest.
<provider
android:authorities="com.facebook.app.FacebookContentProvider123"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
I forgot to change the default name com.facebook.app.FacebookContentProvider123. Finally fixed it by adding a dynamic applicationId as provider name.
<provider
android:authorities="com.facebook.app.FacebookContentProvider.${applicationId}"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
Name Of The Error: Error 505
Problem: This is an unusual error code which is encountered during the updation or installation of the application from Google Play store. It shows up an error message stating “Unknown error code during Application installs 505”.
Following reasons are responsible for this error.
• It is mostly seen when you try to install an outdated version of the app.
• Error 505 can be caused due to the incompatibility of the app with your Android OS version.
• It can also arise due to cache conflict or data crash of the app.
• Error 505 may also arise due to Google Account Sync Problem.
Solution:
• At first restart your Android device, because this step usually works in getting rid off of any type of error. If it didn’t work and then try these simple steps.
• Clear Cache and Data of Google Play Store, Google Service Framework and Download Manager. To do this First of all go to Settings >> then Apps >> select All >> then Google Play Store and Clear cache and Clear data. Also Clear cache and Clear data for Google Services.

Android test project is crashing with error "Test run failed: Instrumentation run failed due to 'Process crashed.'"

My problem seems little different than here Test run failed: Instrumentation run failed due to 'Process crashed.' when testing multiple Android activity
I have followed steps given in the pdf. I have created test project "TestAndroidCalculatorBlackbox" (do we need to have two project one test and one main project, perhaps this could be the reason, cause in Robotium "Getting Started" link they want us to create projects for Notepad), and added jars robotium-solo-5.0.1.jar,robotium-solo-1.6.0.jar, to get rid of red error lines below solo. functions and jay.way package.
I am attaching the error screenshot:
y AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testcalculator"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.testcalculator" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true">
<uses-library android:name="android.test.runner" />
</application>
</manifest>
and I have package added in instrumentation list:
c:\> adb shell pm list instrumentation
instrumentation:PACKAGE.test.test/android.test.InstrumentationTestRunner (target=PACKAGE)
instrumentation:PACKAGE.test.test.test.test.test.test/android.test.InstrumentationTestRunner (target=PACKAGE.test.test)
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)
>> instrumentation:com.testcalculator/android.test.InstrumentationTestRunner (target=com.testcalculator) <<
For those migrating to or currently using Androidx, this error results from using
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" instead of testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner".
Using the latter resolves the error completely.
Don't attach more than one robotium library. robotium-solo-1.6.0.jar should be removed. It's deprecated and you really shouldn't use it anymore.
Is your target application already installed? It should be installed, if you are going to run tests for it. You can not install it only if your test project has reference to target project.
If you have separate APKs for application and instrumentation you should change package in your manifest. You actually have "com.testcalculator" and target package is the same - they should be different. By the way I don't see sources of application in your project, so application part should be removed.
Your error doesn't say much, it's always good to post stacktrace from LogCat.
Read manuals before you start writing tests:
http://developer.android.com/tools/testing/testing_android.html
https://code.google.com/p/robotium/w/list
Had this same problem and fixed it by setting up AndroidJUnitRunner https://developer.android.com/training/testing/junit-runner.html
For the developer who hasn't used androidx yet. Seeing the LogCat solved the issue for me which was deleting these line running in the wrong thread because of RxJava.
companion object {
#get:ClassRule #JvmStatic
val testSchedulerRule = RxImmediateSchedulerRule()
}
In my case it was a StrictMode policy violation caused by AndroidJUnitRunner:
D/StrictMode: StrictMode policy violation: android.os.strictmode.UntaggedSocketViolation: [...]
W/System.err: StrictMode VmPolicy violation with POLICY_DEATH; shutting down.
Disabling the check detectUntaggedSockets() when running an Espresso test fixed it for me. See this question for how to check for that.

Android Application class not found

In my application I use RoboGuice and the configuration for RoboGuice requires to add an Application-class and specify it in the AndroidManifest.xml file in the application-tag using the 'android:name' attribute.
So this is how my applicaiton-tag in the manifest looks like:
<application android:label="Worktime" android:icon="#drawable/logo" android:name=".guice.Application">
This always works and still does when I compile inside my IDE (IntelliJ) and deploy it to my device.
However when I want to run my tests using Ant (and only via Ant, this also still works in the IDE) I have this error on the console:
[exec] android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests:INSTRUMENTATION_RESULT: shortMsg=Unable to instantiate application eu.vranckaert.worktime.guice.Application: java.lang.ClassNotFoundException: eu.vranckaert.worktime.guice.Application in loader dalvik.system.PathClassLoader#44e88928
[exec] INSTRUMENTATION_RESULT: longMsg=java.lang.RuntimeException: Unable to instantiate application eu.vranckaert.worktime.guice.Application: java.lang.ClassNotFoundException: eu.vranckaert.worktime.guice.Application in loader dalvik.system.PathClassLoader#44e88928
This has worked before but started failing since I upgraded my 'Android SDK Tools' to revision 17 and the 'Android SDK Platform-tools' to revision 11.
Anyone who had this issue also or who knows how to fix it?
I think that the error saying
java.lang.ClassNotFoundException:
is occur only when you have create new class Activity and not declare(register) that in manifest file
please check if you have any new activity and not declare(register) that activity in manifest file
Thanks.
we might have encountered the same error - In my case the solution was to separate the Ant targets to two calls (i.e. "ant myParameters myTarget1 myTarget2", and "ant myParameters debug delivery"). Hope this works for you, anyhow - Google need to add better support for their undocumented/faulty changes (and stackoverflow isn't the best place for questions that are not originated in stupidity, as the lifetime of a complex question isn't too long here).

Categories

Resources