908Inc / stickerpipe-chat-sample

Other
76 stars 29 forks source link

NPE in initializing StickersManager #8

Closed KaeMs closed 7 years ago

KaeMs commented 7 years ago

So I get an NPE when I first initialize the StickersManager in Application class like

    StickersManager.initialize("<My API Key>", this);
FATAL EXCEPTION: main
    Process: id.mallinternet.dev, PID: 8036
    java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in vc908.stickerfactory.StickersManager$1@21cc1200
    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:778)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:149)
    at android.app.ActivityThread.main(ActivityThread.java:5268)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.NullPointerException
    at vc908.stickerfactory.StorageManager.getFirstPendingTask(Unknown Source)
    at vc908.stickerfactory.ai.d(Unknown Source)
    at vc908.stickerfactory.ai.c(Unknown Source)
    at vc908.stickerfactory.StickersManager$1.onReceive(Unknown Source)
    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:149) 
    at android.app.ActivityThread.main(ActivityThread.java:5268) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
    at dalvik.system.NativeStart.main(Native Method) 

I think I've followed the steps well in the description and in my build.gradle vc908.stickers:stickerfactory:0.14.3@aar. What am I missing here??

Update

    Caused by: java.lang.NullPointerException
    at vc908.stickerfactory.StorageManager.isStickersExists(Unknown Source)
    at vc908.stickerfactory.StickersManager$1.onReceive(Unknown Source)
    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:149) 
    at android.app.ActivityThread.main(ActivityThread.java:5268) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
dehimb commented 7 years ago

Hi, @KaeMs! Try to use our latest version 0.14.4

dehimb commented 7 years ago

@KaeMs And make sure, you do all this steps

  1. Add content provider
  2. Initialize sdk with your api key
  3. Set current user id
KaeMs commented 7 years ago

@dehimb Hi there, I've added content provider, it's like this

<provider
    android:name="vc908.stickerfactory.provider.StickersProvider"
    android:authorities="this.is.my.package.stickersProvider"
    android:exported="false"/>

And I've initialized it with the API key given.. Website and Android uses the same API key right?

And I set the user ID when I get to login, final step of register, and also the main activity where already registered and logged user is..

I'm going to update my question with different error I get today which happens when.. Sticker existence checking I think in isStickersExists()

dehimb commented 7 years ago

@KaeMs Currently i can't figure out this issue. Can you provide more information about your testing device and steps to reproduce this error?

KaeMs commented 7 years ago

My testing device is Zenfone C with Android version 4.4.2

The steps taken is.. By doing all those above which is setting up Stickerpipe :

  1. Project app file (Repository, compile, etc.)
  2. Adding provider in manifest
  3. Initializing with StickersManager.initialize("<MyAPIKey>", this); in my Application class. I am using multidex btw.

That's all the steps I took to get the crash. I tried using your demo it doesn't crash. I don't have JPush in my app, it is optional right?

dehimb commented 7 years ago

@KaeMs Yes, all additional modules are optional. I think the problem is in integration with your project. I will keep working to figure out this error.

KaeMs commented 7 years ago

Yes, I am quite sure that the problem is as you said. The demo works fine in my same test device.. Do you need any other info from my end?

dehimb commented 7 years ago

@KaeMs You cant try to include sources of sdk and debug with your project Instructions you can find here

KaeMs commented 7 years ago

git submodule add https://github.com/908Inc/stickerfactory.git this line basically copies StickerPipe as a library to my project right? So I can also download the project into my app and do the rest without using git submodule? I am having trouble with that lol

dehimb commented 7 years ago

@KaeMs Yes, you can just download/copy stickerfactory module to your project without using submodule. Clone this repository to your project and follow instructions

KaeMs commented 7 years ago

What's the difference between StickerFactory and StickerPipe? I am sorry for the long reply, I am also working on other things :D

dehimb commented 7 years ago

@KaeMs StickerFactory is core module, you can download its source

KaeMs commented 7 years ago

Got an error saying

Error:(102, 0) CreateProcess error=2, The system cannot find the file specified
<a href="openFile:C:\StudioProjects\...\...\stickerfactory\build.gradle">Open File</a>

// in line
def proc = "/usr/libexec/java_home -v 1.$v".execute()

What does it mean??

EDIT : I googled and it seems that it's a MAC related command is it? What's the equivalent of it in Windows?

dehimb commented 7 years ago

@KaeMs This command used to find path to Java7 and Java8 Put your own path to java to this variables String java8 = getJavaVersion(8) String java7 = getJavaVersion(7)

Or, you can remove all retrolambda dependencies and fix all lambda expressions

KaeMs commented 7 years ago

Lol I thought of that yesterday and when I read the rest of the code I thought I need that getJavaVersion(Integer v) method because of the specific return value. I got another error though, which is

Error:Execution failed for task ':stickerfactory:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Currently looking for what happened..