Home > Blockchain >  SOLVED Xamarin.Forms Java.Lang.RuntimeException: 'Unable to get provider androidx.startup.Initi
SOLVED Xamarin.Forms Java.Lang.RuntimeException: 'Unable to get provider androidx.startup.Initi

Time:04-07

I have this App that fully works on IOS, but when I try to start on Android Device (Phisical, or Emulated) before hit any Method (OnCreate, OnStart, etc) app crashes and give me this error:

Java.Lang.RuntimeException: 'Unable to get provider androidx.startup.InitializationProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.startup.InitializationProvider" on path: DexPathList[[zip file "/data/app/com.myapp.myapp123-enX6MwKxPJAu9d6bm6sajg==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.myapp123-enX6MwKxPJAu9d6bm6sajg==/lib/arm64, /data/app/com.myapp.myapp123-enX6MwKxPJAu9d6bm6sajg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]'

Then after a long search I think the problem may come from two possible points:

-SplashScreen on Android Project

or

-Binding an .AAR file (.AAR file build action is LibraryProjectZip)

But all attempts to fix the problem have failed.

UPDATE

This is Android Manifest

<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application android:requestLegacyExternalStorage="true" android:label="My App" android:theme="@style/MainTheme">



    <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:grantUriPermissions="true" android:exported="false">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" />
    </provider>
    
</application>

UPDATE 2 Code inside filepaths.xml in resources:

<paths>
    <external-path path="." name="mydocuments" />
    <external-path name="external_files" path="."/>
    <files-path name="files" path="."/>
    <internal-path name="internal_files" path="."/>
</paths>

UPDATE 3

I try to:

  • Delete my code in path and replace it whit the whole code that ColeX has mentioned in the link above (nothing)

     <paths xmlns:android="http://schemas.android.com/apk/res/android">
             <external-files-path name="my_images" path="Pictures" />
             <external-files-path name="my_movies" path="Movies" />
     </paths>
    
  • Keep my code and add the code mentioned (nothing)

     <paths xmlns:android="http://schemas.android.com/apk/res/android">
         <external-path path="." name="mydocuments" />
         <external-path name="external_files" path="."/>
         <files-path name="files" path="."/>
         <internal-path name="internal_files" path="."/>
    
         <external-files-path name="my_images" path="Pictures" />
         <external-files-path name="my_movies" path="Movies" />
     </paths>
    
  • Replace "external-path" for "external-files-path" and "internal-path" for "internal-files-path" (nothing )

  • Add and remove

xmlns:android="http://schemas.android.com/apk/res/android"

in all this tries (nothing too)

CodePudding user response:

I can fix the problem, there's nothing wrong in code shared here or in any file, so I think problem has origin from repository where App is loaded. I simply delete the branch (branch equal to master) and create a new one. And now the App in android works well.

Special thanks to ColeX that supports me in this issue and help me to understand that there's nothing wrong in my code

  • Related