我的应用程序在我的模拟器上完美运行,当我在手机上通过USB运行它时。但是,当我从PlayStore下载它时,它会在启动时崩溃 这是日志:
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)
这是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();
}
}
}
我将包名从com.example.xxxxxx更改为com.stackkedteam.feedshare。是不是因为这个原因导致apk无法正常工作?
这是我的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>;
}
以下是我忽略生成APK的gradle消息警告:
这是gradle文件:
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;
}
}
答案 0 :(得分:1)
显然,堆栈跟踪你的proguard文件需要进行一些修改。
-keep class com.parse。 {*; } -keep class io.fabric。 {*; }
因此,首先测试更改并查看在progurd运行时堆栈跟踪上剩下的内容
答案 1 :(得分:0)
好的,事实证明我在
面前错过了一个星号-keep class com.parse.**{ *;}
这就是解决方法。永远想弄清楚。
这是proguard文件:
# 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>;
}