在Playstore上载后,应用程式停止运作

时间:2018-09-13 06:31:29

标签: android android-studio

我刚刚将我的应用程序上传到了Google Play商店,并由于以下代码而崩溃

 Process: com.trifidresearch.trplsg, PID: 30335
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.trifidresearch.trplsg/com.trifidresearch.trplsg.intro.Country}: android.view.InflateException: Binary XML file line #36: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
    at android.app.ActivityThread.access$900(ActivityThread.java:153)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5438)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
 Caused by: android.view.InflateException: Binary XML file line #36: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
    at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at android.support.v7.app.am.v(Unknown Source)
    at android.support.v7.app.am.b(Unknown Source)
    at android.support.v7.app.x.setContentView(Unknown Source)
    at com.trifidresearch.trplsg.intro.Country.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:6303)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) 
    at android.app.ActivityThread.access$900(ActivityThread.java:153) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5438) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
 Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
    at android.view.LayoutInflater.createView(LayoutInflater.java:649)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.am.v(Unknown Source) 
    at android.support.v7.app.am.b(Unknown Source) 
    at android.support.v7.app.x.setContentView(Unknown Source) 
    at com.trifidresearch.trplsg.intro.Country.onCreate(Unknown Source) 
    at android.app.Activity.performCreate(Activity.java:6303) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) 
    at android.app.ActivityThread.access$900(ActivityThread.java:153) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5438) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at android.view.LayoutInflater.createView(LayoutInflater.java:623)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:839) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:842) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:519) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.am.v(Unknown Source) 
    at android.support.v7.app.am.b(Unknown Source) 
    at android.support.v7.app.x.setContentView(Unknown Source) 
    at com.trifidresearch.trplsg.intro.Country.onCreate(Unknown Source) 
    at android.app.Activity.performCreate(Activity.java:6303) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) 
    at android.app.ActivityThread.access$900(ActivityThread.java:153) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5438) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.aj.a()' on a null object reference
    at android.support.v7.widget.at.setBackgroundDrawable(Unknown Source)
    at android.view.View.setBackground(View.java:17244)
    at android.view.View.<init>(View.java:4337)
    at android.widget.ImageView.<init>(ImageView.java:145)
    at android.widget.ImageButton.<init>(ImageButton.java:84)
    at android.widget.ImageButton.<init>(ImageButton.java:80)
    at android.support.v7.widget.at.<init>(Unknown Source)
    at android.support.v7.widget.Toolbar.y(Unknown Source)
    at android.support.v7.widget.Toolbar.c(Unknown Source)
    at android.support.v7.widget.Toolbar.<init>(Unknown Source)
    at android.support.v7.widget.Toolbar.<init>(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Native Method) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:623) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:839) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:842) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:519) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.am.v(Unknown Source) 
    at android.support.v7.app.am.b(Unknown Source) 
    at android.support.v7.app.x.setContentView(Unknown Source) 
    at com.trifidresearch.trplsg.intro.Country.onCreate(Unknown Source) 
    at android.app.Activity.performCreate(Activity.java:6303) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) 
    at android.app.ActivityThread.access$900(ActivityThread.java:153) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5438) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
    09-13 11:50:51.764 1585-2906/? E/ActivityManager: Invalid thumbnail dimensions: 0x0

Android Studio安装后,它在模拟器和手机上都可以正常工作,但是一旦我将其上传到Play商店后,它就无法启动。

我的代码是

package com.trifidresearch.trplsg.intro;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.ListView;

import com.trifidresearch.trplsg.R;

import java.util.ArrayList;
import java.util.Locale;

public class Country extends AppCompatActivity {
    ListView list;
    ListViewAdapter adapter;
    EditText editsearch;
    String[] country;
    ArrayList<CountryNames> arraylist = new ArrayList<CountryNames>();
    @Override
    public void onCreate(Bundle savedInstanceState) {


        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectDiskReads()
                .detectDiskWrites()
                .detectNetwork()   // or .detectAll() for all detectable problems
                .detectAll()
                .penaltyLog()
                .build());

        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .penaltyLog()
                .detectAll()
                .penaltyDeath()
                .build());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listview_main);
        getSupportActionBar().setBackgroundDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.gradi));
    country = new String[] {
            "AFGHANISTAN(93)",
            "ALBANIA(355)",
            "ALGERIA(213)",
            "AMERICAN SAMOA(1684)",
            "ANDORRA(376)",
            "ANGOLA(244)",
            "ZIMBABWE(263)"
    };
    list = findViewById(R.id.listview);
    for (int i = 0; i < country.length; i++)
    {
        CountryNames wp = new CountryNames(country[i]);
        arraylist.add(wp);
    }
    adapter = new ListViewAdapter(this, arraylist);
    list.setAdapter(adapter);
    editsearch = findViewById(R.id.search);
    editsearch.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            String text = editsearch.getText().toString().toLowerCase(Locale.getDefault());
            adapter.filter(text);
        }
        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1,
                                      int arg2, int arg3) {
        }
        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2,
                                  int arg3) {
        }
    });
}

我的gradle文件ID

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        vectorDrawables.useSupportLibrary = true
        applicationId 'com.trifidresearch.trplsg'
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 20201
        versionName '2.2.1'
        useLibrary 'org.apache.http.legacy'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    splits {
        abi {
            enable true
            reset()
            include 'x86_64', 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips'
            //select ABIs to build APKs for
            universalApk true //generate an additional APK that contains all the ABIs
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), "proguard-rules.pro"
            debuggable false
            jniDebuggable false
            renderscriptDebuggable false
            // signingConfig playStoreConfig //Add your own signing config
            pseudoLocalesEnabled false
            zipAlignEnabled true
        }
        debug {

        }
    }
    productFlavors {
    }
    lintOptions {
        checkReleaseBuilds false
    }
    aaptOptions {
        cruncherEnabled = true
    }
    buildToolsVersion '27.0.3'
}


ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 4, 'x86': 5, 'x86_64': 6]

android.applicationVariants.all { variant ->

    variant.outputs.each { output ->
        output.versionCodeOverride = android.defaultConfig.versionCode * 10000 + project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0)
    }
}



dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    implementation 'com.github.clans:fab:1.6.4'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.paypal.sdk:paypal-android-sdk:2.14.2'
    implementation 'org.jsoup:jsoup:1.10.3'
    implementation 'io.github.sac:SocketclusterClientJava:1.7.5'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

2 个答案:

答案 0 :(得分:1)

如果将Proguard minifyEnabled设置为true,那么我认为这会导致崩溃。因此,请尝试将它们添加到/app/proguard-rules.pro中:

-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-keep class com.google.** { *; }
-keep interface com.google.** { *; }

这应该有所帮助,因为您说过您已经在使用最新的支持库。

答案 1 :(得分:1)

我认为您的问题在于此可绘制对象

  

R.drawable.gradi

如您的错误日志最后一行所述

  

无效的缩略图尺寸:0x0

请删除后再检查一次。