Search code examples
javaandroidgradleparse-platform

Cant upload to Parse Server in Android Studio


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 "https://jitpack.io" }

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

  1. I inserted implementation "com.github.parse-community.Parse-SDK-Android:parse:1.25.0" 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("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");
                }
            }
        });

    }

}

My Manifest file:

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

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;->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

Solution

  • 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("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()
        );
      }
    ...
    }
    

    Then last step, add that class in the 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"
        ....
    

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