Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer builds crash if Embedded Social API key isn't provided in gradle.properties #943

Closed
barbeau opened this issue Dec 10, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@barbeau
Copy link
Member

barbeau commented Dec 10, 2018

Summary:

If you don't provide the EmbeddedSocialApiKey_oba=xxxxxxxxxxxxx line in your gradle.properties file (in the /onebusaway-android directory), when building, installing, and executing the app you'll see a crash:

 Process: com.joulespersecond.seattlebusbot, PID: 30919
    java.lang.RuntimeException: Unable to create service com.microsoft.embeddedsocial.service.WorkerService: java.lang.NullPointerException: Attempt to invoke virtual method 'com.microsoft.embeddedsocial.server.IAccountService com.microsoft.embeddedsocial.server.EmbeddedSocialServiceProvider.getAccountService()' on a null object reference
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3552)
        at android.app.ActivityThread.-wrap4(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6938)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.microsoft.embeddedsocial.server.IAccountService com.microsoft.embeddedsocial.server.EmbeddedSocialServiceProvider.getAccountService()' on a null object reference
        at com.microsoft.embeddedsocial.service.handler.SignInHandler.<init>(SignInHandler.java:43)
        at com.microsoft.embeddedsocial.service.IntentProcessorFactory.createIntentProcessor(IntentProcessorFactory.java:44)
        at com.microsoft.embeddedsocial.service.WorkerService.createIntentProcessor(WorkerService.java:23)
        at com.microsoft.embeddedsocial.base.service.AbstractProcessingService.onCreate(AbstractProcessingService.java:49)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3542)
        at android.app.ActivityThread.-wrap4(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6938) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

@acrown-msft I believe this is new behavior with v0.7.3.

Steps to reproduce:

  1. Make sure you don't have the EmbeddedSocialApiKey_oba=xxxxxxxxxxx line in onebusaway-android/gradle.properties
  2. Clean and build and run the app

Expected behavior:

Run without crashing (although Embedded Social features will be hidden)

Observed behavior:

Crash with the above stack trace

Device and Android version:

Samsung Galaxy S8+ with Android 8.0

@barbeau barbeau added the bug label Dec 10, 2018
@barbeau barbeau added this to the v2.3.x milestone Dec 10, 2018
acrown-msft added a commit to acrown-msft/onebusaway-android that referenced this issue Feb 7, 2019
acrown-msft added a commit to acrown-msft/onebusaway-android that referenced this issue Feb 7, 2019
@barbeau barbeau closed this as completed in 7bc023b Feb 8, 2019
@cagryInside
Copy link
Contributor

I see this error on every fresh install.

Steps to reproduce:

  1. Remove the application
  2. Reinstall the application

Console output:

2019-06-24 16:10:49.161 29427-29427/com.joulespersecond.seattlebusbot E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.joulespersecond.seattlebusbot, PID: 29427
    java.lang.RuntimeException: Unable to create service com.microsoft.embeddedsocial.service.WorkerService: java.lang.NullPointerException: Attempt to invoke virtual method 'com.microsoft.embeddedsocial.server.IAccountService com.microsoft.embeddedsocial.server.EmbeddedSocialServiceProvider.getAccountService()' on a null object reference
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3552)
        at android.app.ActivityThread.-wrap4(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6938)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.microsoft.embeddedsocial.server.IAccountService com.microsoft.embeddedsocial.server.EmbeddedSocialServiceProvider.getAccountService()' on a null object reference
        at com.microsoft.embeddedsocial.service.handler.SignInHandler.<init>(SignInHandler.java:43)
        at com.microsoft.embeddedsocial.service.IntentProcessorFactory.createIntentProcessor(IntentProcessorFactory.java:44)
        at com.microsoft.embeddedsocial.service.WorkerService.createIntentProcessor(WorkerService.java:23)
        at com.microsoft.embeddedsocial.base.service.AbstractProcessingService.onCreate(AbstractProcessingService.java:49)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3542)
        at android.app.ActivityThread.-wrap4(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6938) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

@barbeau
Copy link
Member Author

barbeau commented Jun 24, 2019

Thanks @cagryInside! I'm re-opening to check it out.

@barbeau barbeau reopened this Jun 24, 2019
@barbeau
Copy link
Member Author

barbeau commented Jun 27, 2019

I suspect this is related to the new version of Gradle that @cagryInside was using in #988.

@acrown-msft is seeing if he can repro. He can't repro on the master branch.

@acrown-msft
Copy link
Contributor

I am able to repro using distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
and

classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31'
classpath 'com.google.gms:google-services:4.2.0'

@acrown-msft
Copy link
Contributor

This must be a bug in gradle. I was able to fix this issue by re-implementing String.IsEmpty().

I used the above version of gradle and changed util/EmbeddedSocialUtils.java:

    public static boolean isSocialApiKeyDefined() {
        String embeddedSocialApiKey = BuildConfig.EMBEDDED_SOCIAL_API_KEY;
        return embeddedSocialApiKey != null && embeddedSocialApiKey.length() != 0;
    }

@barbeau
Copy link
Member Author

barbeau commented Jun 27, 2019

@acrown-msft Wow, strange. Would you mind opening a PR with this workaround?

barbeau added a commit that referenced this issue Jun 27, 2019
Fix #943 - Workaround for String.isEmpty() being broken in newer version of Gradle
cagryInside pushed a commit to cagryInside/onebusaway-android that referenced this issue Jun 27, 2019
cagryInside pushed a commit to cagryInside/onebusaway-android that referenced this issue Jul 1, 2019
barbeau pushed a commit to cagryInside/onebusaway-android that referenced this issue Jul 3, 2019
… collection feature

Fix OneBusAway#990 - Interpret alert end time of 0 as unending alert

Fix OneBusAway#976 Resolve Guava version conflicts in Embedded Social

Fix OneBusAway#943 Workaround for String.isEmpty() being broken in newer versions of Gradle

WIP Fix OneBusAway#875 - User-travel-behavior - Implement ignore battery optimizations feature

User-travel-behavior - Implement storing device information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants