无法在Android Studio中上传到Parse服务器。

huangapple go评论71阅读模式
英文:

Cant upload to Parse Server in Android Studio

问题

I followed the following guide to include Parse Server in Android Studio:

  1. 下载了文件 PARSE-SDK-Android。

  2. 然后在 build.gradle 中插入了 maven { url "https://jitpack.io" }(带有我的项目名称在括号中)。

  3. 在 gradle.build 模块中插入了 implementation "com.github.parse-community.Parse-SDK-Android:parse:1.25.0"

  4. 最后一个我输入的代码是:

    [Method OnCreate][2]

当我运行这个应用程序时,我总是得到一个异常,无法上传这一个对象到我的服务器。我无法插入指南的最后一步(在 AndroidManifest 中插入 android:name=".App"),因为我会得到一个错误。有人能帮助我吗?谢谢。我不知道该怎么处理我在第一步下载的 SDK,因为除了第一步之外,没有在其他地方提到它。

编辑:我上传了我的代码的重要部分:

应用程序类:

package com.example.hilmi.carlink;

import android.app.Application;
import android.os.Bundle;
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 App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId("myappID") //Change this with your app id
                // if defined
                .clientKey("") //Change this to your client key
                .server("") //your server url
                .build()
        );

        ParseObject object = new ParseObject("ExampleObject");
        object.put("myNumber", "123");

        object.saveInBackground(new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if( e == null)
                {
                    Log.i("Parse Ergebnis", "Erfolgreich");
                }
                else
                {
                    Log.i("Parse Ergebnis", e.getMessage() + " Fehlgeschlagen");
                }
            }
        });
    }
}

我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.hilmi.carlink">

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the "MyLocation" functionality.
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.Internet" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application

        android:name=".App"

        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="ExtraText">

        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/.
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps"></activity>
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Log Cat:

2020-08-08 15:13:15.308 10758-10758/? I/e.hilmi.carlin: Not late-enabling -Xcheck:jni (already on)
...
(其他日志信息)
...
2020-08-08 15:13:19.638 10758-10758/com.example.hilmi.carlink I/Parse Ergebnis: i/o failure Fehlgeschlagen

希望这能帮助你解决你的问题。如果你需要更多帮助,请提供更多详细信息。

英文:

I [followed the following guide to include][1] Parse Server in Android Studio

  1. I downloaded the file PARSE-SDK-Android

  2. Then I inserted maven { url &quot;https://jitpack.io&quot; }

in build.gradle(With my project name in brackets)

  1. I inserted implementation &quot;com.github.parse-community.Parse-SDK-Android:parse:1.25.0&quot; in gradle.build module

  2. The last code I entered, was this:

[Method OnCreate][2]

When I run this app, I always get an exception, cant upload this one object to my server. I couldnt insert the last step of the guide (Inserting android:name=".App" in AndroidManifest, because I get an error. Can someone help me? Thank you. And I dont know what to do with the SDK that I downloaded in the first step, because other than in the first step, it isnt mentioned anywhere else

EDIT: I upload the important areas of my code:

The app class:

package com.example.hilmi.carlink;

import android.app.Application;
import android.os.Bundle;
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 App extends Application { //This class can have any name
    @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId(&quot;myappID&quot;) //Change this with your app id
                // if defined
                .clientKey(&quot;&quot;) //Change this to your client key
                .server(&quot;&quot;) //your server url
                .build()
        );

        ParseObject object = new ParseObject(&quot;ExampleObject&quot;);
        object.put(&quot;myNumber&quot;, &quot;123&quot;);

        object.saveInBackground(new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if( e == null)
                {
                    Log.i(&quot;Parse Ergebnis&quot;, &quot;Erfolgreich&quot;);

                }
                else
                {
                    Log.i(&quot;Parse Ergebnis&quot;, e.getMessage() +&quot; Fehlgeschlagen&quot;);
                }
            }
        });

    }

}

My Manifest file:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;



    package=&quot;com.example.hilmi.carlink&quot;&gt;

    &lt;!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the &quot;MyLocation&quot; functionality.
    --&gt;
    &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
    &lt;uses-permission android:name=&quot;android.permission.Internet&quot; /&gt;
    &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;

    &lt;application


        android:name=&quot;.App&quot;



        android:allowBackup=&quot;true&quot;
        android:icon=&quot;@mipmap/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot;
        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
        android:supportsRtl=&quot;true&quot;
        android:theme=&quot;@style/AppTheme&quot;
        tools:ignore=&quot;ExtraText&quot;&gt;



        &lt;!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file &quot;res/values/google_maps_api.xml&quot;).
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/.
        --&gt;
        &lt;meta-data
            android:name=&quot;com.google.android.geo.API_KEY&quot;
            android:value=&quot;@string/google_maps_key&quot; /&gt;

        &lt;activity
            android:name=&quot;.MapsActivity&quot;
            android:label=&quot;@string/title_activity_maps&quot;&gt;&lt;/activity&gt;
        &lt;activity
            android:name=&quot;.MainActivity&quot;
            android:label=&quot;@string/app_name&quot;
            android:theme=&quot;@style/AppTheme.NoActionBar&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;

The Log Cat:

2020-08-08 15:13:15.308 10758-10758/? I/e.hilmi.carlin: Not late-enabling -Xcheck:jni (already on)
2020-08-08 15:13:15.471 10758-10758/? W/e.hilmi.carlin: Unexpected CPU variant for X86 using defaults: x86
2020-08-08 15:13:16.140 10758-10758/com.example.hilmi.carlink I/e.hilmi.carlin: The ClassLoaderContext is a special shared library.
2020-08-08 15:13:18.081 10758-10783/com.example.hilmi.carlink D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-08-08 15:13:18.093 10758-10783/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Ldalvik/system/CloseGuard;-&gt;get()Ldalvik/system/CloseGuard; (light greylist, reflection)
2020-08-08 15:13:18.093 10758-10783/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Ldalvik/system/CloseGuard;-&gt;open(Ljava/lang/String;)V (light greylist, reflection)
2020-08-08 15:13:18.094 10758-10783/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Ldalvik/system/CloseGuard;-&gt;warnIfOpen()V (light greylist, reflection)
2020-08-08 15:13:18.399 10758-10783/com.example.hilmi.carlink W/e.hilmi.carlin: Verification of void com.parse.ParseCommandCache.maybeRunAllCommandsNow(int) took 111.146ms
2020-08-08 15:13:18.606 10758-10783/com.example.hilmi.carlink W/e.hilmi.carlin: JNI critical lock held for 19.555ms on Thread[14,tid=10783,Runnable,Thread*=0xe47ee000,peer=0x18a805d8,&quot;pool-1-thread-1&quot;]
2020-08-08 15:13:18.628 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Landroid/graphics/drawable/Drawable;-&gt;getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
2020-08-08 15:13:18.628 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden field Landroid/graphics/Insets;-&gt;left:I (light greylist, linking)
2020-08-08 15:13:18.628 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden field Landroid/graphics/Insets;-&gt;right:I (light greylist, linking)
2020-08-08 15:13:18.629 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden field Landroid/graphics/Insets;-&gt;top:I (light greylist, linking)
2020-08-08 15:13:18.629 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden field Landroid/graphics/Insets;-&gt;bottom:I (light greylist, linking)
2020-08-08 15:13:18.774 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Landroid/view/View;-&gt;getAccessibilityDelegate()Landroid/view/View$AccessibilityDelegate; (light greylist, linking)
2020-08-08 15:13:18.815 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Landroid/view/View;-&gt;computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2020-08-08 15:13:18.817 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Landroid/view/ViewGroup;-&gt;makeOptionalFitsSystemWindows()V (light greylist, reflection)
2020-08-08 15:13:18.947 10758-10786/com.example.hilmi.carlink W/e.hilmi.carlin: Verification of okhttp3.Response okhttp3.internal.cache.CacheInterceptor.cacheWritingResponse(okhttp3.internal.cache.CacheRequest, okhttp3.Response) took 177.260ms
2020-08-08 15:13:19.199 10758-10769/com.example.hilmi.carlink I/e.hilmi.carlin: Background concurrent copying GC freed 30038(7MB) AllocSpace objects, 0(0B) LOS objects, 50% free, 1820KB/3MB, paused 14.986ms total 958.551ms
2020-08-08 15:13:19.468 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Landroid/widget/TextView;-&gt;getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
2020-08-08 15:13:19.721 10758-10758/com.example.hilmi.carlink D/OpenGLRenderer: Skia GL Pipeline
2020-08-08 15:13:20.146 10758-10791/com.example.hilmi.carlink D/HostConnection: HostConnection::get() New Host Connection established 0xe5fcf280, tid 10791
2020-08-08 15:13:20.198 10758-10791/com.example.hilmi.carlink D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 
2020-08-08 15:13:20.243 10758-10791/com.example.hilmi.carlink I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2020-08-08 15:13:20.350 10758-10791/com.example.hilmi.carlink I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2020-08-08 15:13:20.351 10758-10791/com.example.hilmi.carlink I/OpenGLRenderer: Initialized EGL, version 1.4
2020-08-08 15:13:20.351 10758-10791/com.example.hilmi.carlink D/OpenGLRenderer: Swap behavior 1
2020-08-08 15:13:20.380 10758-10791/com.example.hilmi.carlink D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
2020-08-08 15:13:20.380 10758-10791/com.example.hilmi.carlink D/EGL_emulation: eglCreateContext: 0xe5f85720: maj 3 min 0 rcv 3
2020-08-08 15:13:20.385 10758-10791/com.example.hilmi.carlink D/EGL_emulation: eglMakeCurrent: 0xe5f85720: ver 3 0 (tinfo 0xe5f834d0)
2020-08-08 15:13:20.447 10758-10791/com.example.hilmi.carlink D/HostConnection: createUnique: call
2020-08-08 15:13:20.448 10758-10791/com.example.hilmi.carlink D/HostConnection: HostConnection::get() New Host Connection established 0xe5fcf500, tid 10791
2020-08-08 15:13:20.454 10758-10791/com.example.hilmi.carlink D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 
2020-08-08 15:13:20.454 10758-10791/com.example.hilmi.carlink E/eglCodecCommon: GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1
2020-08-08 15:13:20.499 10758-10791/com.example.hilmi.carlink D/EGL_emulation: eglMakeCurrent: 0xe5f85720: ver 3 0 (tinfo 0xe5f834d0)
2020-08-08 15:13:20.510 10758-10791/com.example.hilmi.carlink D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 2
2020-08-08 15:13:22.509 10758-10791/com.example.hilmi.carlink I/OpenGLRenderer: Davey! duration=2566ms; Flags=0, IntendedVsync=4977247103390, Vsync=4977663770040, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=4977676584400, AnimationStart=4977676712200, PerformTraversalsStart=4977677797600, DrawStart=4977764138900, SyncQueued=4977805241100, SyncStart=4977806792900, IssueDrawCommandsStart=4977807087100, SwapBuffers=4979175595600, FrameCompleted=4979815328000, DequeueBufferDuration=23043000, QueueBufferDuration=7488000, 
2020-08-08 15:13:23.225 10758-10758/com.example.hilmi.carlink I/Choreographer: Skipped 171 frames!  The application may be doing too much work on its main thread.
2020-08-08 15:13:24.005 10758-10791/com.example.hilmi.carlink I/OpenGLRenderer: Davey! duration=3640ms; Flags=0, IntendedVsync=4977671006930, Vsync=4980521006816, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=4980531425400, AnimationStart=4980531597300, PerformTraversalsStart=4980532585300, DrawStart=4980598997800, SyncQueued=4980621268700, SyncStart=4980621390400, IssueDrawCommandsStart=4980621576500, SwapBuffers=4980846912200, FrameCompleted=4981311498400, DequeueBufferDuration=10036000, QueueBufferDuration=19060000, 
2020-08-08 15:13:39.638 10758-10758/com.example.hilmi.carlink I/Parse&#160;Ergebnis: i/o failure Fehlgeschlagen

答案1

得分: 1

最后一步表示您有一个扩展了Application的类,然后在onCreate方法中初始化Parse:

public class App extends Application { //此类可使用任何名称
  @Override
  public void onCreate() {
    super.onCreate();
    Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId("YOUR_APP_ID") //将此替换为您的应用程序ID
      //如果定义了clientKey
      .clientKey("YOUR_CLIENT_KEY") //将此替换为您的客户端密钥
      .server("http://localhost:1337/parse/") //您的服务器URL
      .build()
    );
  }
...
}

然后,最后一步是将该类添加到AndroidManifest中:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.appname">

    ...

    <application
        android:name=".App"
        android:label="@string/app_name">
    ....

应该可以工作。否则,请检查确切的错误是什么,我们可以提供帮助。
英文:

The last step indicates that you have a class that extends Application then initialize Parse in the onCreate method:

public class App extends Application { //This class can have any name
  @Override
  public void onCreate() {
    super.onCreate();
    Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId(&quot;YOUR_APP_ID&quot;) //Change this with your app id
      // if defined
      .clientKey(&quot;YOUR_CLIENT_KEY&quot;) //Change this to your client key
      .server(&quot;http://localhost:1337/parse/&quot;) //your server url
      .build()
    );
  }
...
}

Then last step, add that class in the AndroidManifest:

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    package=&quot;com.example.appname&quot;&gt;

    ...

    &lt;application
        android:name=&quot;.App&quot;
        android:label=&quot;@string/app_name&quot;
    ....

Should work. Otherwise please check what the error is exacly and we can help.

huangapple
  • 本文由 发表于 2020年8月8日 07:37:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/63310396.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定