Search code examples
androidparse-platformapkproguard

APK error: Android app runs perfectly fine on emulator/device but when I download from the PlayStore the app always crashes on startup


My app works perfectly fine on my emulator and when I run it through the usb on my phone. However when i download it from PlayStore, it crashes on start up Here is the Log:

java.lang.AbstractMethodError: abstract method "void android.app.Application$ActivityLifecycleCallbacks.onActivityCreated(android.app.Activity, android.os.Bundle)"
at android.app.Application.dispatchActivityCreated(Application.java:190)
at android.app.Activity.onCreate(Activity.java:954)
at com.stackkedteam.feedshare.DispatchActivity.onCreate(Unknown Source)  //<--- this line is bolded in the log
at android.app.Activity.performCreate(Activity.java:6097)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5430)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)

Here is the DispatchActivity:

package com.stackkedteam.feedshare;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.parse.ParseUser;

 /* Activity which starts an intent for either the logged in (MainActivity) or logged out
 * (SignUpOrLoginActivity) activity.
 */
public class DispatchActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        // Check if there is current user info
        if (ParseUser.getCurrentUser() != null) {
            // Start an intent for the logged in activity
            startActivity(new Intent(this, MealListActivity.class));
            finish();
        } else {
            // Start and intent for the logged out activity
            startActivity(new Intent(this, SignUpOrLoginActivity.class));
            finish();
        }
    }
}

I changed the package name from com.example.xxxxxx to com.stackkedteam.feedshare. Is it because of that reason that the apk doesn't work?

Here's my proguard-rules.pro:

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-keepattributes SourceFile,LineNumberTable
-keep class com.parse.*{ *; }
-dontwarn com.parse.**
-dontwarn io.fabric.**
-dontwarn bolts.**
-dontwarn com.squareup.picasso.**
-keep class com.stackkedteam.feedshare.DispatchActivity {*;}
-keepclasseswithmembernames class * {
    native <methods>;
}

Here is the gradle message warning that I ignored to generate the APK:

enter image description here

And here is the gradle file:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 11
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.stackkedteam.feedshare"
        minSdkVersion 11
        targetSdkVersion 23
    }

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

dependencies {
    //compile 'com.android.support:support-v4:18.0.0'
    compile 'com.android.support:support-v4:23.0.+'
    compile files('libs/Parse-1.4.3.jar')
    compile 'com.parse.bolts:bolts-android:1.+'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.3@aar') {
        transitive = true;
    }
}

Solution

  • Okay, so it turns out I was missing an asterisk on my in front of

    -keep class com.parse.**{ *;}
    

    And that's the fix. Took forever to figure out.

    Here is the proguard file:

    # Add project specific ProGuard rules here.
    # By default, the flags in this file are appended to flags specified
    # in /Users/Ben/Library/Android/sdk/tools/proguard/proguard-android.txt
    # You can edit the include path and order by changing the proguardFiles
    # directive in build.gradle.
    #
    # For more details, see
    #   http://developer.android.com/guide/developing/tools/proguard.html
    
    # Add any project specific keep options here:
    
    # If your project uses WebView with JS, uncomment the following
    # and specify the fully qualified class name to the JavaScript interface
    # class:
    #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
    #   public *;
    #}
    
    -keepattributes SourceFile,LineNumberTable
    -keep class com.parse.**{ *; }
    -dontwarn com.parse.**
    -dontwarn io.fabric.**
    -dontwarn bolts.**
    -dontwarn com.squareup.picasso.**
    -keep class com.stackkedteam.feedshare.DispatchActivity {*;}
    -keepclasseswithmembernames class * {
        native <methods>;
    }