无法在 Android Studio 中上传到 Parse Server

Cant upload to Parse Server in Android Studio

我[按照以下指南在 Android Studio

中包含][1] Parse Server
  1. 我下载了文件 PARSE-SDK-Android

  2. 然后我插入maven { url "https://jitpack.io" }

在build.gradle(括号内是我的项目名称)

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

  2. 我输入的最后一个密码是这样的:

[方法 OnCreate][2]

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

编辑: 我上传代码的重要区域:

应用程序 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("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>

日志猫:

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;->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;->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;->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,"pool-1-thread-1"]
2020-08-08 15:13:18.628 10758-10758/com.example.hilmi.carlink W/e.hilmi.carlin: Accessing hidden method Landroid/graphics/drawable/Drawable;->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;->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;->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;->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;->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;->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;->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;->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;->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 Ergebnis: i/o failure Fehlgeschlagen

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

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("YOUR_APP_ID") //Change this with your app id
      // if defined
      .clientKey("YOUR_CLIENT_KEY") //Change this to your client key
      .server("http://localhost:1337/parse/") //your server url
      .build()
    );
  }
...
}

然后最后一步,在AndroidManifest中添加class:

    <?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"
    ....

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