Search code examples
pythonandroidkivycrashbuildozer

Android app crash with error Unknown admin


I've written a Kivy Python android app and created an .apk file using buildozer. After installing the app, when trying to open it - it crash. In the logs I see the following:

2022-12-28 14:08:57.318 1816-2097/? E/EnterpriseDeviceManagerService: isMdmAdminPresentInternal() : failed. 
    java.lang.IllegalArgumentException: Unknown admin: ComponentInfo{com.samsung.klmsagent/com.samsung.klmsagent.deviceAdminManager.AdminReceiver}
        at com.android.server.enterprise.EnterpriseDeviceManagerServiceImpl.findAdmin(EnterpriseDeviceManagerServiceImpl.java:1593)
        at com.android.server.enterprise.EnterpriseDeviceManagerServiceImpl.isMdmAdminPresentInternal(EnterpriseDeviceManagerServiceImpl.java:2722)
        at com.android.server.enterprise.EnterpriseDeviceManagerServiceImpl.isMdmAdminPresent(EnterpriseDeviceManagerServiceImpl.java:2752)
        at com.samsung.android.knox.EnterpriseDeviceManager.isMdmAdminPresent(EnterpriseDeviceManager.java:10)
        at com.android.server.am.ActivityManagerService.updateActivityUsageStats(ActivityManagerService.java:3369)
        at com.android.server.am.ActivityManagerService$LocalService.updateActivityUsageStatsWithIntent(ActivityManagerService.java:19576)
        at com.android.server.wm.ActivityTaskManagerService$$ExternalSyntheticLambda22.accept(Unknown Source:27)
        at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:363)
        at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:204)
        at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.os.HandlerThread.run(HandlerThread.java:67)
        at com.android.server.ServiceThread.run(ServiceThread.java:44)

I've read about it and understood that need to change the owner using adb: ./adb shell dpm set-device-owner com.samsung.klmsagent/.deviceAdminManager.AdminReceiver

I've tried it, but get the following error:

Exception occurred while executing 'set-device-owner':
java.lang.IllegalArgumentException: Unknown admin: ComponentInfo{com.samsung.klmsagent/com.samsung.klmsagent.deviceAdminManager.AdminReceiver}
        at com.android.server.devicepolicy.DevicePolicyManagerService.findAdmin(DevicePolicyManagerService.java:3152)
        at com.android.server.devicepolicy.DevicePolicyManagerService.setActiveAdmin(DevicePolicyManagerService.java:3726)
        at com.android.server.devicepolicy.DevicePolicyManagerServiceShellCommand.runSetDeviceOwner(DevicePolicyManagerServiceShellCommand.java:256)
        at com.android.server.devicepolicy.DevicePolicyManagerServiceShellCommand.onCommand(DevicePolicyManagerServiceShellCommand.java:89)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.devicepolicy.DevicePolicyManagerService.onShellCommand(DevicePolicyManagerService.java:10669)
        at android.os.Binder.shellCommand(Binder.java:1085)
        at android.os.Binder.onTransact(Binder.java:903)
        at android.app.admin.IDevicePolicyManager$Stub.onTransact(IDevicePolicyManager.java:6790)
        at android.os.Binder.execTransactInternal(Binder.java:1321)
        at android.os.Binder.execTransact(Binder.java:1280)

buildozer spec file:

[app]

# (str) Title of your application
title = Dikduk

# (str) Package name
package.name = dikduk

# (str) Package domain (needed for android/ios packaging)
package.domain = org.dikduk

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (str) Application versioning (method 1)
version = 0.1

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy==master,pillow

# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait

# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 1.9.1

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0

# (str) The format used to package the app for release mode (aab or apk or aar).
android.release_artifact = aab

#
# iOS specific
#

ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master

ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.10.0

# (bool) Whether or not to sign the code
ios.codesign.allowed = false

[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1

    

Can someone please help with that? Thanks :)


Solution

  • I've found the issue by using logcat of Android Studio in Verbose lop level: Change the phone work in developer mode. Connect the phone to the computer and then saw that issue that caused the problem