Android发布版本运行狂野

时间:2016-08-10 06:05:35

标签: android android-studio

我的应用程序已在调试版中经过全面测试,并且运行正常。另一方面,发布版本崩溃了。因此,我已采取措施调试发行版本(BuildType Release:debuggable true)。现在我可以看到应用程序调用onCreateView来获取一个段,该段在启动时未加载。在这个onCreateView里面,我一步一步地看到,该程序在另一个函数内部进行了一步(是的,不是在开头,而是在中间的某个地方)。所以我写了#34;跑狂"。

这是我的build.gradle:

apply plugin: 'com.android.application'

android {
    signingConfigs {
        Signed {
            keyAlias 'xxx-certificate'
            keyPassword 'aaaaaaaaa'
            storeFile file('E:/_Arbeiten/AndroidStudioProjects/KeyStore/xxxKeystore')
            storePassword '9999999'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
    }
    buildTypes {
        release {
            signingConfig signingConfigs.Signed
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "test_version", "No"
            debuggable true
        }
        debug {
            resValue "string", "test_version", "Yes"
        }
    }
    productFlavors {
        German {
            applicationId "de.xxx.android.xxxDict.DE"
            versionCode 25
            versionName "3.0"
        }

        English {
            applicationId "de.xxx.android.xxxDict.EN"
            versionCode 25
            versionName "3.0"
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile project(':lvl')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.google.android.gms:play-services-identity:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
}

直到现在我都试过了:

  1. 从Release中删除minifyEnabled和proguardFiles - 同样的问题
  2. 也为Debug调试signedConfig并测试此版本 - 可行
  3. 我还重启了Android Studio并多次清理了该项目。问题仍然存在。发布版本绝对无法正常运行。

    我知道compileSdkVersion 23不是最新版本,但是如果我使用版本24,我还有很多其他问题。

    事实:调试工作正常(签名或未签名) 事实:发布版本在启动时立即崩溃

    让某人了解会发生什么?

    编辑:在LogCat中,我看到以下内容(Program Malibu):

    I/ActivityManager(  913): Start proc de.Malibu.android.MalibuDict.DE for activity de.Malibu.android.MalibuDict.DE/de.Malibu.dictionary.MainActivity: pid=192
    39 uid=10141 gids={50141, 9997, 3003, 1028, 1015} abi=x86
    I/ActivityManager(  913): Launched start pid= [ 19239]
    I/ActivityManager(  913): START u0 {cmp=de.Malibu.android.MalibuDict.DE/de.Malibu.dictionary.ExpDownloaderActivity} from uid 10141 on display 0
    W/ActivityManager(  913): Activity pause timeout for ActivityRecord{2d4fbe19 u0 de.Malibu.android.MalibuDict.DE/de.Malibu.dictionary.MainActivity t465}
    I/ActivityManager(  913): Launched start pid= [ -1]
    I/ActivityManager(  913): Launched start pid= [ 19239]
    D/ConnectivityService(  913): listenForNetwork for NetworkRequest [ id=122, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]
    D/ConnectivityService(  913): handleRegisterNetworkRequest checking NetworkAgentInfo [WIFI () - 103]
    D/ConnectivityService(  913): apparently satisfied.  currentScore=100
    E/AndroidRuntime(19239): FATAL EXCEPTION: main
    E/AndroidRuntime(19239): Process: de.Malibu.android.MalibuDict.DE, PID: 19239
    E/AndroidRuntime(19239): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.Malibu.android.MalibuDict.DE/de.Malibu.dictionary.MainActivity}: ja
    va.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
    E/AndroidRuntime(19239):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
    E/AndroidRuntime(19239):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
    I/ActivityManager(  913): Start proc com.google.android.apps.plus for service com.google.android.apps.plus/.service.EsSyncAdapterService: pid=19282 uid=10099 gids={50099,
    9997, 3003, 3002, 1028, 1015} abi=x86
    W/ResourcesManager(19282): Asset path '/system/framework/com.google.android.maps.jar' does not exist or contains no resources.
    I/ActivityManager(  913): Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=19309 uid=10025 gids={50025, 9997, 3
    003, 1028, 1015, 1023} abi=x86
    I/ActivityManager(  913): Killing 19072:com.asus.email:exchange/u0a9 (adj 15): empty #9
    W/libprocessgroup(  913): failed to open /acct/uid_10009/pid_19072/cgroup.procs: No such file or directory
    I/ActivityManager(  913): Killing 19049:com.asus.email/u0a9 (adj 15): empty #9
    W/libprocessgroup(  913): failed to open /acct/uid_10009/pid_19049/cgroup.procs: No such file or directory
    W/ActivityManager(  913): Activity destroy timeout for ActivityRecord{2d4fbe19 u0 de.Malibu.android.MalibuDict.DE/de.Malibu.dictionary.MainActivity t465 f}
    W/ActivityManager(  913): Activity destroy timeout for ActivityRecord{26c581db u0 de.Malibu.android.MalibuDict.DE/de.Malibu.dictionary.ExpDownloaderActivity t465
    f}
    D/TaskPersister(  913): removeObsoleteFile: deleting file=465_task.xml
    D/BatteryService(  913): Sending ACTION_BATTERY_CHANGED.  level:93, scale:100, status:2, health:2, present:true, voltage: 4211, temperature: 369, technology: Li-ion, AC po
    wered:false, USB powered:true, Wireless powered:false, dock AC powered:false, dock status:1, dock level:0, pad AC powered:false, pad status:1, pad level:0, pack AC powered
    :false, pack status:1, pack level:0, icon:17303371, invalid charger:0
    D/PowerUI ( 1043): dismiss Low BatteryWarning  level: 93
    D/PowerUI ( 1043): show_hot_plug_dialog: true
    D/PowerUI ( 1043): show_otg_cable_dialog: true
    D/PowerUI ( 1043): plugged:true mBatteryStatus:2 mBatteryLevel: 93 mOldQcLevel: 0 mQcLevel:0 mShowCharingReminder:false
    W/InputMethodManagerService(  913): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2d069398 attribute=null, token
    = android.os.BinderProxy@14bd55eb
    I/ActivityManager(  913): Process de.Malibu.android.MalibuDict.DE (pid 19239) has died
    W/ActivityManager(  913): App Op not allow to restart app de.Malibu.android.MalibuDict.DE/10141
    

    请记住我说的话: Programm调用onCreateView,该段不应在开始时加载。这是一个详细视图,稍后在列表中单击后会打开。

    当我将我的发布版本调试并在onCreateView上设置断点时,我可以单步直到第32行。下一步进入第78行!这不是很疯狂吗?

    这是我的onCreateView(我只添加了两个提到的行号32和78):

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.detailview, container, false);
            if (savedInstanceState != null) {
                // Restore last state
                mIndex = savedInstanceState.getInt("Index");
                mLexItemList = savedInstanceState.getParcelableArrayList("List");
            }
    
            Bundle bundle = this.getArguments();
            wv = (WebView) v.findViewById(R.id.webView);
            btnSpeaker = (ImageButton) v.findViewById(R.id.btnSpeaker);
            btnSpeaker.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (mIndex < mLexItemList.size()) {
                        btnSpeaker.setImageResource(R.drawable.speaker_i);
                        btnSpeaker.setEnabled(false);
                        mLexItemList.get(mIndex).Sprechen(onSprechenFertig);
                    }
                }
            });
            btnSpeaker.setImageResource(R.drawable.speaker_i);
            btnSpeaker.setEnabled(false);
            btnMemo = (Button) v.findViewById(R.id.btnMemo);
            btnMemo.setEnabled(false);
            btnNext = (ImageButton) v.findViewById(R.id.btnNext);
            btnNext.setEnabled(false);
            btnBack = (ImageButton) v.findViewById(R.id.btnBack);
            btnBack.setEnabled(false);
            if (bundle != null) {
    32            if (bundle.getInt("Memo", 0) == 1) {
                    btnMemo.setEnabled(true);
                    btnMemo.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            String suchwort;
                            int setSound=0;
                            LexItem lexItem = mLexItemList.get(mIndex);
    
                            HistoryDatabase db = new HistoryDatabase(getActivity());
    
                            if (mSuchwort.equals(""))
                                suchwort = lexItem.getThai();
                            else
                                suchwort = mSuchwort;
                            if (suchwort.substring(0, 2).equals("* ")) {
                                suchwort = suchwort.substring(2);
                            } else if (suchwort.substring(0, 2).equals("+ ")) {
                                suchwort = suchwort.substring(2);
                            }
                            String lang = "";
                            switch (lexItem.getLexTyp()) {
                                case ltDeutschThai: lang = "Text"; break;
                                case ltThaiDeutsch: lang = "Thai"; break;
                                case ltThaiumschriftDeutsch: lang = "Trans"; break;
                            }
                            String detail = lexItem.getBeschreibung();
                            if (detail.indexOf("*:;") > 0)
                                setSound++;
                            if ((detail.substring(0, 1).equals("*")) | (detail.substring(0, 1).equals("+"))) {
                                detail = detail.substring(1);
                            }
                            db.saveHistory(-1, lang, suchwort, lexItem.getThai(), lexItem.getLautschriftRoh(),
                                    detail, lexItem.getVoicedatei(), setSound);
    
                            Toast t = Toast.makeText(getActivity(), R.string.memosave, Toast.LENGTH_LONG );
                            t.show();
                        }
                    });
                }
                if (mLexItemList.size() > 1) {
                    if (bundle.getInt("Next", 0) == 1) {
                        btnNext.setEnabled(true);
                        btnNext.setImageResource(R.drawable.btn_next_a);
                        btnNext.setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                if (mIndex < mLexItemList.size() - 1) {
    78                              mIndex++;
                                    refreshView();
                                    setSelection(mIndex);
                                }
                            }
                        });
                    }
                    if (bundle.getInt("Back", 0) == 1) {
                        btnBack.setEnabled(true);
                        btnNext.setImageResource(R.drawable.btn_previous_a);
                        btnBack.setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                if (mIndex > 0) {
                                    mIndex--;
                                    refreshView();
                                    setSelection(mIndex);
                                }
                            }
                        });
                    }
                }
            }
            return v;
        }
    

    再次:此问题仅在发布版本上,而不是在调试版本中!因此代码必须正常,问题可能在gradle中?

0 个答案:

没有答案