解析:ACL 无法将数据发送到服务器

Posted

技术标签:

【中文标题】解析:ACL 无法将数据发送到服务器【英文标题】:Parse : ACL Cannot send data to server 【发布时间】:2017-05-16 15:15:06 【问题描述】:

大家好,我遇到了无法将数据发送到服务器的问题。起初我尝试在 StarterApplication.java 处通过写入 (ParseObject) 发送数据并且它可以工作。但是当在 处写入 (ParseObject) 时>MainActivity.java 不工作。为什么?希望你们能帮我解决这个问题。TQ

错误信息

LOGCAT

  05-17 15:03:28.128 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_301a24434564d06ffe12a56ff7da00f52e346cb8-classes.dex
    05-17 15:03:28.132 1735-2020/com.parse.starter I/art: jiangtaottt DexFile_ThirdDex2oatNative 222/data/data/com.parse.starter/files/instant-run/dex/slice-com.google.android.gms-play-services-ads-9.4.0_51356d099b9793fc820c0bb434ab4f81fcffdbec-classes.dex
    05-17 15:03:28.133 1735-2020/com.parse.starter I/art: jiangtaottt get_parent_dir: parent: /data/data/com.parse.starter  i=28
    05-17 15:03:28.133 1735-2020/com.parse.starter I/art: jiangtaottt DexFile_ThirdDex2oatNative is dexing   /data/data/com.parse.starter/dexing-flag
    05-17 15:03:28.142 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_301a24434564d06ffe12a56ff7da00f52e346cb8-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_301a24434564d06ffe12a56ff7da00f52e346cb8-classes.dex
    05-17 15:03:28.143 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_48aa21b4e8403c1677e9ab895231d93ecfe54c25-classes.dex
    05-17 15:03:28.155 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_48aa21b4e8403c1677e9ab895231d93ecfe54c25-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_48aa21b4e8403c1677e9ab895231d93ecfe54c25-classes.dex
    05-17 15:03:28.156 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-multidex-1.0.1_3727344502c75ae6bc14c2f0efce22a2f915d89d-classes.dex
    05-17 15:03:28.253 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-multidex-1.0.1_3727344502c75ae6bc14c2f0efce22a2f915d89d-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-multidex-1.0.1_3727344502c75ae6bc14c2f0efce22a2f915d89d-classes.dex
    05-17 15:03:28.259 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-mediarouter-v7-23.0.0_2ef8fc2a0c6a2fe4d1d819e09cfdd1e223aceadd-classes.dex
    05-17 15:03:28.344 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-mediarouter-v7-23.0.0_2ef8fc2a0c6a2fe4d1d819e09cfdd1e223aceadd-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-mediarouter-v7-23.0.0_2ef8fc2a0c6a2fe4d1d819e09cfdd1e223aceadd-classes.dex
    05-17 15:03:28.345 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.4.0_7c9c4c583792bd7fa91047936d492183a0729810-classes.dex
    05-17 15:03:28.452 1735-2006/com.parse.starter I/art: jiangtaottt DexFile_ThirdDex2oatNative success 333/data/data/com.parse.starter/files/instant-run/dex/slice-com.google.android.gms-play-services-analytics-9.4.0_d335cf156da033164f9e20361a0eb22e92eec4ae-classes.dex
    05-17 15:03:28.458 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.4.0_7c9c4c583792bd7fa91047936d492183a0729810-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.4.0_7c9c4c583792bd7fa91047936d492183a0729810-classes.dex
    05-17 15:03:28.460 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.4.0_e295f74e431be9c2235019e0b34f4458989a4df7-classes.dex
    05-17 15:03:28.479 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.4.0_e295f74e431be9c2235019e0b34f4458989a4df7-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.4.0_e295f74e431be9c2235019e0b34f4458989a4df7-classes.dex
    05-17 15:03:28.480 1735-1735/com.parse.starter I/art: jiangtaottt OpenDexFilesFromOat open_oat_file.get() == nullptr /data/data/com.parse.starter/files/instant-run/dex/slice-bolts-tasks-1.4.0_e967602cedb3cdf27c5916205188b8064fdde338-classes.dex
    05-17 15:03:28.487 1735-1735/com.parse.starter E/System: elements.add : /data/data/com.parse.starter/files/instant-run/dex/slice-bolts-tasks-1.4.0_e967602cedb3cdf27c5916205188b8064fdde338-classes.dex  null   /data/data/com.parse.starter/files/instant-run/dex/slice-bolts-tasks-1.4.0_e967602cedb3cdf27c5916205188b8064fdde338-classes.dex
    05-17 15:03:28.556 1735-1755/com.parse.starter W/art: Suspending all threads took: 8.438ms
    05-17 15:03:28.559 1735-1755/com.parse.starter I/art: Background sticky concurrent mark sweep GC freed 1108(304KB) AllocSpace objects, 14(352KB) LOS objects, 33% free, 1419KB/2MB, paused 9.975ms total 21.194ms
    05-17 15:03:28.613 1735-1735/com.parse.starter I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
    05-17 15:03:28.763 1735-1750/com.parse.starter W/art: Suspending all threads took: 9.527ms
    05-17 15:03:29.212 1735-1735/com.parse.starter D/wangcy9: setStatusIcon occur wrong theme!
    05-17 15:03:29.361 1735-1735/com.parse.starter W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
    05-17 15:03:29.627 1735-1735/com.parse.starter I/ViewRootImpl: CPU Rendering VSync enable = true
    05-17 15:03:29.647 1735-2096/com.parse.starter D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
    05-17 15:03:29.657 1735-1735/com.parse.starter D/Atlas: Validating map...
    05-17 15:03:29.703 1735-2096/com.parse.starter I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8916_64_LA.BR.1.2.4_RB1__release_AU (Ibddc658e36)
                                                                 OpenGL ES Shader Compiler Version: E031.25.03.04
                                                                 Build Date: 09/08/15 Tue
                                                                 Local Branch: 
                                                                 Remote Branch: quic/LA.BR.1.2.4_rb1.17
                                                                 Local Patches: NONE
                                                                 Reconstruct Branch: NOTHING
    05-17 15:03:29.705 1735-2096/com.parse.starter I/OpenGLRenderer: Initialized EGL, version 1.4
    05-17 15:03:29.722 1735-2096/com.parse.starter D/OpenGLRenderer: Enabling debug mode 0
    05-17 15:03:29.733 1735-2096/com.parse.starter I/qdutils: PartialUpdate status: Disabled
    05-17 15:03:29.733 1735-2096/com.parse.starter I/qdutils: Left Align: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Width Align: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Top Align: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Height Align: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Min ROI Width: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Min ROI Height: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Needs ROI Merge: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Dynamic Fps: Disabled
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Min Panel fps: 0
    05-17 15:03:29.734 1735-2096/com.parse.starter I/qdutils: Max Panel fps: 0
    05-17 15:03:29.854 1735-1735/com.parse.starter I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@702c751 time:367176349
    05-17 15:03:31.168 1735-1735/com.parse.starter I/SaveInBackground: Failed.Errorcom.parse.ParseRequest$ParseRequestException: Invalid ACL.

StarterApplication.java

/*
 * Copyright (c) 2015-present, Parse, LLC.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
package com.parse.starter;

import android.app.Application;
import android.util.Log;

import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseUser;
import com.parse.SaveCallback;


public class StarterApplication extends Application 

  @Override
  public void onCreate() 
    super.onCreate();

    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    // Add your initialization code here
    Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
            .applicationId("appID")
            .clientKey("ClientKey")
            .server("url")
            .build()
    );
  /*
    ParseObject object = new ParseObject("ExampleObject");
    object.put("myNumber", "123");
    object.put("myString", "rob");

    object.saveInBackground(new SaveCallback () 
      @Override
      public void done(ParseException ex) 
        if (ex == null) 
          Log.i("Parse Result", "Successful!");
         else 
          Log.i("Parse Result", "Failed" + ex.toString());
        
      
    );

      */

    ParseUser.enableAutomaticUser();

    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    defaultACL.setPublicWriteAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);

  

MainActivity.java

/*
 * Copyright (c) 2015-present, Parse, LLC.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
package com.parse.starter;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Switch;

import com.parse.LogInCallback;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseAnonymousUtils;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseUser;
import com.parse.SaveCallback;


public class MainActivity extends AppCompatActivity 


  @Override
  protected void onCreate(Bundle savedInstanceState) 
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

      //create object  = Score
      ParseObject score = new ParseObject("Score");
      score.put("username","michael");
      score.put("score",40);
      score.saveEventually(new SaveCallback() 
          @Override
          public void done(ParseException e) 
              if(e == null)
                  Log.i("SaveInBackground","Successfully");
              else
                  Log.i("SaveInBackground","Failed.Error"+e.toString());
              
          
      );

    ParseAnalytics.trackAppOpenedInBackground(getIntent());
  


【问题讨论】:

发布完整的 LogCat 并且不要将代码/LogCat 放入图像中。 @Sufian 已经添加了完整的 LogCat 先生。 @khoi 您是否尝试删除 ParseACL defaultACL = new ParseACL(); defaultACL.setPublicReadAccess(true); defaultACL.setPublicWriteAccess(true); ParseACL.setDefaultACL(defaultACL, true); ?并与新用户一起测试 @JulienKode 我尝试删除您刚刚提到的代码及其工作!。只是想知道,你的意思是测试一个新用户? 这只是为了确定:) 【参考方案1】:

请删除

ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
defaultACL.setPublicWriteAccess(true);
ParseACL.setDefaultACL(defaultACL, true);

【讨论】:

以上是关于解析:ACL 无法将数据发送到服务器的主要内容,如果未能解决你的问题,请参考以下文章

为啥我无法正确获取图像数据或无法将数据发送到服务器?

Kafka安全机制解析及重构(四) ACL权限控制

ACL——访问控制列表

带有解析服务器的 Mandrill 无法进行 heroku 迁移

将数据发送回阿波罗服务器时出错(错误请求错误)

GWT 将大量数据从服务器发送到客户端的最佳实践