作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用程序在我的模拟器上运行得很好,当我通过手机上的 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;
}
}
最佳答案
很明显,根据堆栈跟踪,您的 proguard 文件需要进行一些修改。
-保持类 com.parse.{ *; }-保持类 io.fabric.{ *;
所以首先测试更改并查看当 progurd 运行时堆栈跟踪中剩下的内容
关于android - APK 错误 : Android app runs perfectly fine on emulator/device but when I download from the PlayStore the app always crashes on startup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34003991/
我是一名优秀的程序员,十分优秀!