java - Android install apk error on Android N -
question:i failure when try install apks on android n. part error info.
java.lang.nullpointerexception: attempt invoke virtual method 'android.content.res.xmlresourceparser android.content.pm.providerinfo.loadxmlmetadata(android.content.pm.packagemanager, java.lang.string)' on null object reference @ android.support.v4.content.fileprovider.parsepathstrategy(fileprovider.java:583) @ android.support.v4.content.fileprovider.getpathstrategy(fileprovider.java:557) at
android.support.v4.content.fileprovider.geturiforfile(fileprovider.java:399) @ me.hades.androidsafer.utils.systemutils.installapk(systemutils.java:59) @ me.hades.androidsafer.utils.systemutils.installapk(systemutils.java:51) @ me.hades.androidsafer.activity.splashactivity$2.completed(splashactivity.java:154) @ com.liulishuo.filedownloader.filedownloadmessenger.handovermessage(filedownloadmessenger.java:341) @ com.liulishuo.filedownloader.filedownloadmessagestation$uihandlercallback.dispose(filedownloadmessagestation.java:169) @ com.liulishuo.filedownloader.filedownloadmessagestation$uihandlercallback.handlemessage(filedownloadmessagestation.java:160) @ android.os.handler.dispatchmessage(handler.java:98) @ android.os.looper.loop(looper.java:154) @ android.app.activitythread.main(activitythread.java:6077) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:865) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:755)
this part manifest.xml
<provider android:name="android.support.v4.content.fileprovider" android:authorities="me.hades.androidsafer.fileprovider" android:exported="false" android:granturipermissions="true"> <meta-data android:name="android.support.file_provider_paths" android:resource="@xml/file_paths"/> </provider>
this part @xml/file_paths.xml
<?xml version="1.0" encoding="utf-8"?> <paths> <external-path path="download/" name="download" /> <external-files-path name="download" path="download/" /> </paths>
installapk() function:
public static void installapk(context context,file file) { intent intent = new intent(intent.action_view); if (build.version.sdk_int >= build.version_codes.n) { intent.setflags(intent.flag_grant_read_uri_permission); uri contenturi = fileprovider.geturiforfile(context, buildconfig.application_id + ".fileprovider", file); intent.setdataandtype(contenturi, "application/vnd.android.package-archive"); } else { intent.setdataandtype(uri.fromfile(file), "application/vnd.android.package-archive"); intent.setflags(intent.flag_activity_new_task); } context.startactivity(intent); }
how fix error? english not well. thinks
check question might shall helpful you. problem in file provider.
Comments
Post a Comment