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

Could not send ACRA Post responseCode=405 message=Method Not Allowed #409

Closed
mpraki opened this issue Mar 24, 2016 · 12 comments
Closed

Could not send ACRA Post responseCode=405 message=Method Not Allowed #409

mpraki opened this issue Mar 24, 2016 · 12 comments

Comments

@mpraki
Copy link

mpraki commented Mar 24, 2016

When we generate release build of our app, we are getting the below exception. Tried acra-4.8.2 and 4.8.5 versions, same behaviour. When we generate the debug build, ACRA logs are perfectly getting published to the database. We have our database in cloudant.com.

We didn't have this issue in our last app release but don't know how its happening in the current release alone. We used same version(4.8.2) of ACRA for both previous and current releases.

Stacktrace:

03-24 21:45:35.234  11405-11789/? I/ACRA﹕ Sending report /data/user/0/com.mycomp/app_ACRA-approved/2016-03-24T21:45:35.146+05:30-IS_SILENT.stacktrace
03-24 21:45:37.488  11405-11789/? W/ACRA﹕ Could not send ACRA Post responseCode=405 message=Method Not Allowed
03-24 21:45:37.496  11405-11789/? E/ACRA﹕ Failed to send crash report for /data/user/0/com.mycomp/app_ACRA-approved/2016-03-24T21:45:35.146+05:30-IS_SILENT.stacktrace
    org.acra.sender.ReportSenderException: Error while sending JSON report via Http POST
            at org.acra.sender.HttpSender.send(HttpSender.java:236)
            at org.acra.sender.ReportDistributor.sendCrashReport(ReportDistributor.java:102)
            at org.acra.sender.ReportDistributor.distribute(ReportDistributor.java:70)
            at org.acra.sender.SenderService.onHandleIntent(SenderService.java:69)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.os.HandlerThread.run(HandlerThread.java:61)
     Caused by: java.io.IOException: Host returned error code 405
            at org.acra.util.HttpRequest.send(HttpRequest.java:167)
            at org.acra.sender.HttpSender.send(HttpSender.java:233)
            at org.acra.sender.ReportDistributor.sendCrashReport(ReportDistributor.java:102)
            at org.acra.sender.ReportDistributor.distribute(ReportDistributor.java:70)
            at org.acra.sender.SenderService.onHandleIntent(SenderService.java:69)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.os.HandlerThread.run(HandlerThread.java:61)
@mpraki mpraki changed the title Could not send ACRA Post responseCode=405 message=Method Not Allowed - Release build issue Could not send ACRA Post responseCode=405 message=Method Not Allowed Mar 24, 2016
@william-ferguson-au
Copy link
Member

By default ACRA POSTs requests. HTTP 405 means that the server does not expect to be given a request of tat type on that URL. http://www.checkupdown.com/status/E405.html

If you are getting different behaviour between your debug vs your release version, then you must be changing the config between the two. What is your debug config? WHat is your release config?

@mpraki
Copy link
Author

mpraki commented Mar 25, 2016

The only difference between our debug and release build is, we are running
proguard rules for release but not for debug. The thing is, I completely
excluded ACRA classes from proguard but that too didn't help.

@william-ferguson-au
Copy link
Member

ACRA ships with all the Proguard rules it requires.

I would suggest that if the only difference between your debug and release is Proguard, then you have incorrectly configured Proguard for ACRA.

@william-ferguson-au
Copy link
Member

Have a look at the ACRA proguard config.

If that doesn't clarify things, then post your Proguard config.

@mpraki
Copy link
Author

mpraki commented Mar 28, 2016

Looks like proguard isn't an issue. I have commented everything(minifyEnabled & proguardFiles) within release build and tried but that too didn't help. Below are the ACRA related configs in our project.

build.gradle:

    buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }

    dependencies {
        ...
        ...
        compile('ch.acra:acra:4.8.5'){
            transitive = true;
            exclude module: 'support-v4'
            exclude module: 'support-annotations'
        }
    }

proguard-rules.pro:

    #ACRA specifics
    # Restore some Source file names and restore approximate line numbers in the stack traces,
    # otherwise the stack traces are pretty useless
    -keepattributes SourceFile,LineNumberTable

    # ACRA needs "annotations" so add this...
    # Note: This may already be defined in the default "proguard-android-optimize.txt"
    # file in the SDK. If it is, then you don't need to duplicate it. See your
    # "project.properties" file to get the path to the default "proguard-android-optimize.txt".
    -keepattributes *Annotation*

    # Keep all the ACRA classes
    -keep class org.acra.** { *; }

    # Don't warn about removed methods from AppCompat
    -dontwarn android.support.v4.app.NotificationCompat*

    # These classes are constucted with reflection.
    -keep public class * implements org.acra.sender.ReportSenderFactory { public <methods>; }

@william-ferguson-au
Copy link
Member

As a sanity check, switch off Proguard entirely for your release build.
At the moment you have just switched off minify.

@mpraki
Copy link
Author

mpraki commented Mar 29, 2016

@william-ferguson-au , as per the documentation, setting minifyEnabled as false should turn off proguard. Please correct me if I'm wrong.

http://stackoverflow.com/a/27107444/710817

@william-ferguson-au
Copy link
Member

Sorry, I can't answer a Gradle question because I don't use it.

Proguard has the ability to minify AND to obfuscate.
That config looks like it is not minifying but is probably still obfuscating.
Try either remove the Proguard config from your build or adding '-dontobfuscate' to your proguard config.
See http://stackoverflow.com/questions/15031386/how-do-i-disable-proguard-for-building-my-android-app

@mpraki
Copy link
Author

mpraki commented Mar 29, 2016

@william-ferguson-au - as per this Android documentation, setting minifyEnabled as false should disable proguard completely.

Quote from Android site,

When you create a project in Android Studio or with the Gradle build system, the minifyEnabled property in the build.gradle file enables and disables ProGuard for release builds.

Also it states,

ProGuard runs only when you build your application in release mode, so you do not have to deal with obfuscated code when you build your application in debug mode.

From the above readings, I strongly believe something is wrong in the proguard config(either in my project or in ACRA, which I yet to find).

I'm yet to try the -dontobfuscate flag you suggested, will try in my evening and let you know the result. Below is the one that I'm going to try.

-dontobfuscate
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!code/allocation/variable,!field

@william-ferguson-au
Copy link
Member

OK, I don't think I can say this any more plainly.

To totally rule out Proguard being the issue - remove it from your build.

@mpraki
Copy link
Author

mpraki commented Mar 30, 2016

@william-ferguson-au , very very sorry for wasting your time. Issue is with my app. The cloudant URL for debug and release modes are different. When I enabled ACRA.DEV_LOGGING = true, found this straight away. again sorry for wasting your time. There is nothing wrong in the ACRA proguard.

@mpraki mpraki closed this as completed Mar 30, 2016
@william-ferguson-au
Copy link
Member

Glad you got it working.
For what it's worth I see little value in having a separate ReportServer for dev and release. It is just one more thing that will catch you when you go to release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants