Stickers: [Android] App gets forced to close

Created on 31 Dec 2018  路  13Comments  路  Source: WhatsApp/stickers

Specifications
OS Level: Android 9.0
Device Manifacture: Nokia (7.1)

Stickers
My stickers do comply with the sticker requirements (512x512 and < 100 KB): [YES]
My tray icon does comply with the requirements (96x96 and < 50 KB): [YES]
I am using [WebP] images for stickers.

The problem
Hello Guys, i downloaded the latest Commit yesterday and directly build the "template" to an app so i could first see how it looks and reacts.

After that i decided to get my own Stickers into the app but the app gets always "Forced Closed"

I only edited the packageid (as told in the readme) and the names of the files in the content.json

But the app doesnt start anymore, what could be the problem?

Android

All 13 comments

Hey @DanielK1511,
Could you please post an error log (logcat)?

My tray icon does comply with the requirements (96x96 and < 50 KB): [Maybe?]

And please confirm this :)

@MarivinJWendt Is it possible to logcat without root? because my device
isnt rooted yet and it seems theres no way to root my device yet.

@MarvinJWendt could the tray icon cause the force? because the icon is not this size

Hey @DanielK1511,
Logcat is a feature integrated in Android Studio. If you connect your mobile phone via a USB cable, your phone will report it's logs to Android Studio, which will show it. You just need to turn on USB debugging in the developer settings. You do not need a rooted mobile for that. If you want to use logcat in the future you can read more here: https://developer.android.com/studio/run/device

@MarvinJWendt could the tray icon cause the force? because the icon is not this size

I actually don't know what happens when the tray icon isn't the required size. But anyway you should definitely have the tray icon in the required size.
If this doesn't help, you should consider posting the logcat output (it normally shows exactly where the error is).

Ok Thank you, i try it in about 3 days because im in Hospital right now

It should show error in the phone when tray icon is not correct. It should not crash. So logcat will be helpful. Thanks @MarvinJWendt for moderating.

@MarvinJWendt @simonzhexu OK i have everything setup now, but how do i know wich log is from the app?

Ok The LogCat window says this is the start of the crash:

2019-01-04 19:24:12.918 11038-11038/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.bykrieger.sticker1, PID: 11038
    java.lang.RuntimeException: Unable to get provider com.example.samplestickerapp.StickerContentProvider: java.lang.RuntimeException: contents.json file has some issues: Use JsonReader.setLenient(true) to accept malformed JSON at line 18 column 10
        at android.app.ActivityThread.installProvider(ActivityThread.java:6452)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5994)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5900)
        at android.app.ActivityThread.access$1100(ActivityThread.java:202)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:198)
        at android.app.ActivityThread.main(ActivityThread.java:6729)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.RuntimeException: contents.json file has some issues: Use JsonReader.setLenient(true) to accept malformed JSON at line 18 column 10
        at com.example.samplestickerapp.StickerContentProvider.readContentFile(StickerContentProvider.java:149)
        at com.example.samplestickerapp.StickerContentProvider.getStickerPackList(StickerContentProvider.java:155)
        at com.example.samplestickerapp.StickerContentProvider.onCreate(StickerContentProvider.java:90)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1936)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1911)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6447)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5994)聽
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5900)聽
        at android.app.ActivityThread.access$1100(ActivityThread.java:202)聽
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)聽
        at android.os.Handler.dispatchMessage(Handler.java:107)聽
        at android.os.Looper.loop(Looper.java:198)聽
        at android.app.ActivityThread.main(ActivityThread.java:6729)聽
        at java.lang.reflect.Method.invoke(Native Method)聽
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)聽
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)聽
     Caused by: android.util.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 18 column 10
        at android.util.JsonReader.syntaxError(JsonReader.java:1160)
        at android.util.JsonReader.checkLenient(JsonReader.java:838)
        at android.util.JsonReader.nextInObject(JsonReader.java:660)
        at android.util.JsonReader.peek(JsonReader.java:349)
        at android.util.JsonReader.hasNext(JsonReader.java:319)
        at com.example.samplestickerapp.ContentFileParser.readStickers(ContentFileParser.java:145)
        at com.example.samplestickerapp.ContentFileParser.readStickerPack(ContentFileParser.java:106)
        at com.example.samplestickerapp.ContentFileParser.readStickerPacks(ContentFileParser.java:47)
        at com.example.samplestickerapp.ContentFileParser.parseStickerPacks(ContentFileParser.java:28)
        at com.example.samplestickerapp.StickerContentProvider.readContentFile(StickerContentProvider.java:147)
        at com.example.samplestickerapp.StickerContentProvider.getStickerPackList(StickerContentProvider.java:155)聽
        at com.example.samplestickerapp.StickerContentProvider.onCreate(StickerContentProvider.java:90)聽
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1936)聽
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1911)聽
        at android.app.ActivityThread.installProvider(ActivityThread.java:6447)聽
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5994)聽
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5900)聽
        at android.app.ActivityThread.access$1100(ActivityThread.java:202)聽
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)聽
        at android.os.Handler.dispatchMessage(Handler.java:107)聽
        at android.os.Looper.loop(Looper.java:198)聽
        at android.app.ActivityThread.main(ActivityThread.java:6729)聽
        at java.lang.reflect.Method.invoke(Native Method)聽
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)聽
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)聽

I cant really tell whats wrong here please help.

Hey @DanielK1511.

Caused by: java.lang.RuntimeException: contents.json file has some issues: Use JsonReader.setLenient(true) to accept malformed JSON at line 18 column 10

Caused by: android.util.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 18 column 10

These lines mean that your contents.json file has malformed data in it.

If you can't find the error you can post the file here :)

PS: https://jsonlint.com/ is a great tool to find errors in JSON files.

Ok this is what the validator dropped following:

Error: Parse error on line 14:
... "meme1.webp",               },              {                   "image
---------------------^
Expecting 'STRING', got '}'

Here my content.json:

{
  "android_play_store_link": "",
  "ios_app_store_link": "",
  "sticker_packs": [
    {
      "identifier": "1",
      "name": "Memepack1",
      "publisher": "MemeLord-app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

    {
      "identifier": "2",
      "name": "Memepack 2",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

    {
      "identifier": "3",
      "name": "Memepack 3",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

    {
      "identifier": "4",
      "name": "Memepack 4",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

    {
      "identifier": "5",
      "name": "Memepack 5",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

    {
      "identifier": "6",
      "name": "Memepack 6",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

    {
      "identifier": "7",
      "name": "Memepack 7",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email":"",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp",

        },
        {
          "image_file": "meme2.webp",

        },
        {
          "image_file": "meme3.webp",

        },
        {
          "image_file": "meme4.webp",

        },
        {
          "image_file": "meme5.webp",

        },
        {
          "image_file": "meme6.webp",

        },
        {
          "image_file": "meme7.webp",

        },
        {
          "image_file": "meme8.webp",

        },
        {
          "image_file": "meme9.webp",

        },
        {
          "image_file": "meme10.webp",

        },

      ]
    }

  ]
}

Hey @DanielK1511,
I reformatted your JSON file and corrected some errors.

When adding new stickerpacks you always made a new line between:
image

Make sure that the packs are seperated with a comma like this:
image

Fixed file:


contents.json (Click to expand)

{
  "android_play_store_link": "",
  "ios_app_store_link": "",
  "sticker_packs": [
    {
      "identifier": "1",
      "name": "Memepack1",
      "publisher": "MemeLord-app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    },
    {
      "identifier": "2",
      "name": "Memepack 2",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    },
    {
      "identifier": "3",
      "name": "Memepack 3",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    },
    {
      "identifier": "4",
      "name": "Memepack 4",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    },
    {
      "identifier": "5",
      "name": "Memepack 5",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    },
    {
      "identifier": "6",
      "name": "Memepack 6",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    },
    {
      "identifier": "7",
      "name": "Memepack 7",
      "publisher": "MemeLord app",
      "tray_image_file": "Spongebob.png",
      "publisher_email": "",
      "publisher_website": "",
      "privacy_policy_website": "",
      "license_agreement_website": "",
      "stickers": [
        {
          "image_file": "meme1.webp"
        },
        {
          "image_file": "meme2.webp"
        },
        {
          "image_file": "meme3.webp"
        },
        {
          "image_file": "meme4.webp"
        },
        {
          "image_file": "meme5.webp"
        },
        {
          "image_file": "meme6.webp"
        },
        {
          "image_file": "meme7.webp"
        },
        {
          "image_file": "meme8.webp"
        },
        {
          "image_file": "meme9.webp"
        },
        {
          "image_file": "meme10.webp"
        }
      ]
    }
  ]
}

Thank you Alot!

thank you again, everything is working properly now. I close the issue now.

Was this page helpful?
0 / 5 - 0 ratings