不幸的是,应用程序已停止并导致E / installed:系统目录0:/ system / app /

时间:2018-08-06 06:19:47

标签: java android

我正在构建一个android应用程序,首先,用户使用ID注册一个帐户,然后登录,系统将检查该用户使用的设备是否与注册时使用的设备相同。当设备相同时,系统将向服务器发送令牌。这是检查用户设备时的方法:

private void cekDataLogin(final String serial, final String device) throws IOException, JSONException {
    @SuppressLint("StaticFieldLeak")
    class dataLogin extends AsyncTask<Void, Void, String> {
        private final WeakReference<MainActivity> mActivityRef;
        private dataLogin(MainActivity activity) {
            mActivityRef = new WeakReference<>(activity);
        }
        protected String doInBackground(Void[] params) {
            String response = "";
            HashMap<String, String> map = new HashMap<>();
            try {
                HttpRequest req = new HttpRequest(ipAddress + "/preserv/index.php?func=tokenget&ser=" + serial + "&dev=" + device);
                response = req.prepare(HttpRequest.Method.GET).sendAndReadString();
            } catch (Exception e) {
                response = e.getMessage();
            }
            return response;
        }
        protected void onPostExecute(String result) {
            onTaskCompletedPin(result, jsoncode);
        }
    }
    new dataLogin(this).execute();
}
public void onTaskCompletedPin(String response, int serviceCode) {
    Log.d("responsejson", response);
    switch (serviceCode) {
        case jsoncode:
                try {
                    postDataToken();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
    }
} 

这是发送新令牌时的方法:

 private void postDataToken() throws IOException, JSONException {
    final String android_id = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
    final String token = SharedPreference.getInstance(MainActivity.this).getDeviceToken();
    @SuppressLint("StaticFieldLeak")
    class dataToken extends AsyncTask<Void, Void, String> {
        private final WeakReference<MainActivity> mActivityRef;
        private dataToken(MainActivity activity) {
            mActivityRef = new WeakReference<>(activity);
        }
        protected String doInBackground(Void[] params) {
            String response = "";
            HashMap<String, String> map = new HashMap<>();
            try {
                HttpRequest req = new HttpRequest(ipAddress + "/preserv/index.php?func=devuptoken&ser=" + Build.SERIAL + "&dev=" + android_id + "&token=" + token);
                response = req.prepare(HttpRequest.Method.POST).withData(map).sendAndReadString();
            } catch (Exception e) {
                response = e.getMessage();
            }
            return response;
        }
        protected void onPostExecute(String result) {
            onTaskCompletedDevice(result, jsoncode);
        }
    }
    new dataToken(this).execute();
}
public void onTaskCompletedDevice(String response, int serviceCode) {
    Log.d("responsejson", response);
    switch (serviceCode) {
        case jsoncode:
            if (response.contains("sukses")) {
                final String android_id = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
                if (KEY_CON.equalsIgnoreCase("Wifi")) {
                    if (ipAddress.contains("10.20.")) {
                        URL = "http://10.20.2.14/personal/index.php?serial=" + Build.SERIAL + "&device=" + android_id;
                    } else {
                        URL = "http://36.67.40.162:9024/personal/index.php?serial=" + Build.SERIAL + "&device=" + android_id;
                    }
                } else {
                    URL = "http://36.67.40.162:9024/personal/index.php?serial=" + Build.SERIAL + "&device=" + android_id;
                }
                webView.loadUrl(URL);
            } else if (response.contains("failed")) {
                try {
                    postDataToken();
                } catch (Exception e) {
                    toastMessage("Can't generate token");
                }
            } else {
                toastMessage("ELSE");
            }
    }
}

,导致不幸的App停止运行,并且错误logcat如下所示:

08-06 14:11:13.948 10722-10722/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.launcher.rsupsanglah.personalNotif, PID: 10722
java.lang.NullPointerException: println needs a message
    at android.util.Log.println_native(Native Method)
    at android.util.Log.d(Log.java:164)
    at com.launcher.rsupsanglah.personal.MainActivity.m(Unknown Source)
    at com.launcher.rsupsanglah.personal.MainActivity.a(Unknown Source)
    at com.launcher.rsupsanglah.personal.MainActivity$a.a(Unknown Source)
    at com.launcher.rsupsanglah.personal.MainActivity$a.onPostExecute(Unknown Source)
    at android.os.AsyncTask.finish(AsyncTask.java:632)
    at android.os.AsyncTask.access$600(AsyncTask.java:177)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5942)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.
    run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
08-06 14:11:14.013 3006-10804/? E/android.os.Debug: ro.product_ship = true
ro.debug_level = 0x4f4c
08-06 15:09:01.573 3006-3589/? V/ApplicationPolicy: isApplicationStateBlocked 
userId 0 pkgname com.launcher.rsupsanglah.personalNotif
08-06 15:09:01.573 3006-3589/? W/ActivityManager:   Force finishing activity 
com.launcher.rsupsanglah.personalNotif/
com.launcher.rsupsanglah.personal.MainActivity
08-06 15:09:01.588 3006-27720/? W/DropBoxManagerService: Dropping: 
data_app_crash (1228 > 0 bytes)
08-06 15:09:01.598 27618-27719/? I/FirebaseCrash: Sending crashes
08-06 15:09:01.603 27618-27719/? I/System.out: (HTTPLog)-Static: 
isSBSettingEnabled false
08-06 15:09:01.633 3006-27722/? E/android.os.Debug: ro.product_ship = true
ro.debug_level = 0x4f4c
08-06 15:09:01.653 3006-3035/? D/StatusBarManagerService: manageDisableList 
userId=0 what=0x0 pkg=WindowManager.LayoutParams
08-06 15:09:01.653 3006-3037/? D/PointerIcon: setMouseIconStyle1 pointerType: 
1001iconType:101 flag:0
setMouseCustomIcon IconType is same.101
08-06 15:09:01.653 3006-3006/? D/CrashAnrDetector: NO DROPBOX ENTRY for 
:data_app_crash 1533539341593
08-06 15:09:01.653 3006-3037/? D/PointerIcon: setHoveringSpenIconStyle1 
pointerType: 10001iconType:1 flag:0
08-06 15:09:01.658 3006-3037/? D/PointerIcon: setHoveringSpenCustomIcon 
IconType is same.1
08-06 15:09:01.663 2352-2352/? I/SurfaceFlinger: id=972 createSurf (49x49),1 
flag=4, qersonalNot
08-06 15:09:01.663 21591-21591/? W/ContextImpl: Calling a method in the 
system process without a qualified user: 
android.app.ContextImpl.startService:2051 
android.content.ContextWrapper.startService:533 
android.content.ContextWrapper.startService:533 
com.samsung.android.sm.common.SmartManagerReceiver.b:199 
com.samsung.android.sm.common.SmartManagerReceiver.onReceive:93 
08-06 15:09:01.663 3006-3449/? D/ActivityManager: startService 
callerProcessName:com.samsung.android.sm, calleePkgName: 
com.samsung.android.sm
caller:android.app.ApplicationThreadProxy@18ebc41, r.packageName 
:com.samsung.android.sm
08-06 15:09:01.673 3006-3585/? D/ActivityManager: 
caller:android.app.ApplicationThreadProxy@37c86727, r.packageName 
:com.google.android.gms
08-06 15:09:01.683 3006-4255/? D/ActivityManager: startService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms
caller:android.app.ApplicationThreadProxy@17c9db7d, r.packageName 
:com.google.android.gms
08-06 15:09:01.683 3006-3175/? I/OpenGLRenderer: Initialized EGL, version 1.4
08-06 15:09:01.693 3006-3449/? D/ActivityManager: bindService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms, action: 
com.google.android.gms.phenotype.service.START
08-06 15:09:01.703 3006-3175/? I/OpenGLRenderer: HWUI protection enabled for 
context ,  &this =0x9e959f88 ,&mEglDisplay = 1 , &mEglConfig = -1641421900 
08-06 15:09:01.703 3006-3019/? D/ActivityManager: startService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms
08-06 15:09:01.708 3006-3019/? D/ActivityManager: 
caller:android.app.ApplicationThreadProxy@7a9336c, r.packageName 
:com.google.android.gms
08-06 15:09:01.723 3006-3587/? D/ActivityManager: bindService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms, action: com.google.android.gms.clearcut.service.START
08-06 15:09:01.738 3006-3413/? D/ActivityManager: bindService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms, action: com.google.android.gms.udc.service.START
08-06 15:09:01.758 3006-3585/? D/ActivityManager: startService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms
caller:android.app.ApplicationThreadProxy@10932be9, r.packageName 
:com.google.android.gms
08-06 15:09:01.768 3006-3586/? D/ActivityManager: startService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms
caller:android.app.ApplicationThreadProxy@24164f9c, r.packageName 
:com.google.android.gms
08-06 15:09:01.778 3006-3449/? D/ConnectivityService: returning 
getActiveNetworkInfo :[type: WIFI[] - WIFI, state: CONNECTED/CONNECTED, 
reason: (unspecified), extra: "KECOA SALTO", roaming: false, failover: false, 
isAvailable: true, isConnectedToProvisioningNetwork: false]
08-06 15:09:01.788 27618-27719/? I/System.out: 
KnoxVpnUidStorageknoxVpnSupported API value returned is false
08-06 15:09:01.788 3006-3373/? D/ActivityManager: startService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms
08-06 15:09:01.793 3006-3373/? D/ActivityManager: 
caller:android.app.ApplicationThreadProxy@18699da5, r.packageName 
:com.google.android.gms
08-06 15:09:01.798 3006-3590/? D/ActivityManager: startService 
callerProcessName:com.google.android.gms, calleePkgName: 
com.google.android.gms
caller:android.app.ApplicationThreadProxy@259e957a, r.packageName 
:com.google.android.gms
08-06 15:09:01.808 3006-4578/? D/ActivityManager: startService 
 callerProcessName:com.google.android.gms, calleePkgName: 
 com.google.android.gms
08-06 15:09:01.813 3006-4578/? D/ActivityManager: 
caller:android.app.ApplicationThreadProxy@2c6d012b, r.packageName 
:com.google.android.gms
08-06 15:09:01.918 4024-27128/? I/qtaguid: Untagging socket 87
08-06 15:09:02.128 3006-3032/? W/ActivityManager: Activity pause timeout for 
ActivityRecord{1df5a9bd u0 
com.launcher.rsupsanglah.personalNotif
/com.launcher.rsupsanglah.personal.MainActivity t392 f}
mDVFSHelper.acquire()
08-06 15:09:02.138 3006-3032/? V/WindowOrientationListener: 
mSContextAutoRotationListener.getProposedRotation, mbResultFaceDectection: 
false mSContextAutoRotationListener.getProposedRotation, Rotation: -1
08-06 15:09:02.138 3006-3032/? V/WindowManager: 
rotationForOrientationLw(orient=-1, last=0); user=0 USER_ROTATION_LOCKED 
sensorRotation=-1 mLidState=-1 mDockMode=0 mHdmiPlugged=false
08-06 15:09:02.143 3006-3032/? V/WindowOrientationListener: 
mSContextAutoRotationListener.getProposedRotation, mbResultFaceDectection: 
false mSContextAutoRotationListener.getProposedRotation, Rotation: -1
08-06 15:09:02.148 2352-2352/? I/SurfaceFlinger: id=973 createSurf 
(1080x1920),1 
flag=404, TubSettings
08-06 15:09:02.243 18041-18041/? E/AccessibilityManager: assistantMenuUpdate 
invoking from manager:
08-06 15:09:02.323 3006-3043/? D/ActivityManager: bindService 
callerProcessName:android, calleePkgName: com.android.defcontainer, action: 
null
08-06 15:09:02.333 2360-2360/? E/installd: system dir 0 : /system/app/
08-06 15:09:02.338 3006-3449/? D/UsbSettingsManager: hasDefaults: 
com.launcher.rsupsanglah.personalNotif FALSE
08-06 15:09:02.378 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.378 2360-2360/? E/installd: system dir 0 : /system/app/
08-06 15:09:02.388 18041-18041/? W/ResourceType: Failure getting entry for 
0x7f020000 (t=1 e=0) (error -75)
08-06 15:09:02.388 18041-18041/? W/PackageManager: Failure retrieving 
resources 
for com.sec.android.provider.badge: Resource ID #0x7f020000
08-06 15:09:02.403 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.403 3006-4578/? D/SecContentProvider2: uri = 1 selection = 
getApplicationUninstallationEnabled
mCursor = null
08-06 15:09:02.403 3006-4578/? D/ApplicationPolicy: 
getApplicationUninstallationEnabled
getApplicationUninstallationEnabled :  enabled true
08-06 15:09:02.403 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
08-06 15:09:02.408 3006-3373/? D/ActivityManager: post active user change for 
0 fullscreen true record.isFloatingActivity() false
08-06 15:09:02.408 3006-3373/? D/KnoxTimeoutHandler: postActiveUserChange for 
user 0
08-06 15:09:02.413 3006-3006/? D/PersonaManagerService: getPersonasForUser(): 
returning null!
08-06 15:09:02.408 3006-3373/? I/KnoxTimeoutHandler: postActiveUserChange, 
showWhenLocked: false
08-06 15:09:02.413 3006-3006/? D/KnoxTimeoutHandler: handleActiveUserChange 
for user 0
08-06 15:09:02.428 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.428 2360-2360/? E/installd: system dir 0 : /system/app/
08-06 15:09:02.448 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.448 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
08-06 15:09:02.468 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.468 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
08-06 15:09:02.488 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.488 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
system dir 2 : /vendor/app/
system dir 3 : /oem/app/
08-06 15:09:02.513 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.513 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
system dir 2 : /vendor/app/
system dir 3 : /oem/app/
08-06 15:09:02.518 18041-18041/? I/Timeline: Timeline: Activity_idle id: 
android.os.BinderProxy@8c69e1e time:24624275
08-06 15:09:02.548 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.548 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
system dir 2 : /vendor/app/
system dir 3 : /oem/app/
08-06 15:09:02.593 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.593 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
system dir 2 : /vendor/app/
system dir 3 : /oem/app/
08-06 15:09:02.613 3006-3043/? D/PackageManager: remove MCS_UNBIND message 
and Posting MCS_UNBIND 10 secs later
08-06 15:09:02.613 2360-2360/? E/installd: system dir 0 : /system/app/
system dir 1 : /system/priv-app/
system dir 2 : /vendor/app/
system dir 3 : /oem/app/

有什么主意吗?我是android的新手,有时应用程序可以正常运行(在发生类似多次错误之后),但是当我清除数据/卸载后,主要导致此E / installd:system dir 0:/ system / app /,有时甚至是E / FirebaseInstanceId:令牌检索失败:SERVICE_NOT_AVAILABLE,因为生成新令牌时使用的是Firebase。我已经设置了仅在设备连接到互联网时生成令牌。

1 个答案:

答案 0 :(得分:-1)

static jint android_util_Log_println_native(JNIEnv* env, jobject clazz,
    jint bufID, jint priority, jstring tagObj, jstring msgObj)
{
    const char* tag = NULL;
    const char* msg = NULL;

    if (msgObj == NULL) {
        jniThrowNullPointerException(env, "println needs a message");
        return -1;
    }
    // Rest of the method
}

按照用于在Android中打印消息的本机打印方法,您的消息对象应为非null值。

在您的情况下,响应对象为null。所以在打印消息之前添加空检查

if(null != response)
{
    Log.d("responsejson", response);
}

如果您仍要打印,即使响应对象为null,它的值是多少。尝试在下面的行中使用。

Log.d("responsejson", "Response is "+response);