0

I am currently developing an app to use a barcode scanner, one of the requirements is that app autostart with the device.

so, google on that I found some interest thinks, but when I implemented it fails epicly, the app does not starts.

this is mainfest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="AppConsulta.Droid" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="24" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="AppConsulta.Android" android:icon="@drawable/Logo_Jumbo_Cencosud">
        <activity android:name="MainActivity" />
        <receiver android:name=".BootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
</application>

and this is my receiver

namespace AppConsulta.Droid
{
    [BroadcastReceiver]
    [IntentFilter(new[] { Intent.ActionBootCompleted }, Priority = (int)IntentFilterPriority.LowPriority)]
    public class BootReceiver : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            Intent serviceStart = new Intent(context, typeof(MainActivity));
            serviceStart.AddFlags(ActivityFlags.NewTask);
            context.StartActivity(serviceStart);
        }

    }
}

using adb.exe I manage to extract the log of the device

and it shows this

10-22 16:33:00.412  2007  2007 E AndroidRuntime: FATAL EXCEPTION: main

10-22 16:33:00.412  2007  2007 E AndroidRuntime: Process: AppConsulta.Droid, PID: 2007

10-22 16:33:00.412  2007  2007 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate receiver AppConsulta.Droid.BootReceiver: java.lang.ClassNotFoundException: Didn't find class "AppConsulta.Droid.BootReceiver" on path: DexPathList[[zip file "/data/app/AppConsulta.Droid-1/base.apk"],nativeLibraryDirectories=[/data/app/AppConsulta.Droid-1/lib/arm, /data/app/AppConsulta.Droid-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
Ali Khaki
  • 1,184
  • 1
  • 13
  • 24
  • ClassNotFoundException, your manifest is incorrect : https://stackoverflow.com/questions/49403069/xamarin-android-receiver-on-boot-completed-error/49415199#49415199 – SushiHangover Oct 22 '18 at 17:47
  • `INSTALL_PARSE_FAILED_MANIFEST_MALFORMED` Something in your manifest is incorrect, why not remove the manual changes you made and use `Attributes`, refer to the link in my comment – SushiHangover Oct 22 '18 at 18:28
  • I have finally correct it and now is going ok, thanks a lot for the help =) – Ulises Ruz Oct 22 '18 at 19:22

0 Answers0