解決:新建項目(默認AndroidX)改成Android項目啓動總是閃退

Android Studio3.5.2,新建項目都是默認AndroidX,想改成android項目,改動如下所示:

一.gradle.properties(Project Properties),改成如下:

android.useAndroidX=false
android.enableJetifier=false

二.build.gradle(Module:app),改成如下:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
}

三.MainActivity,引用改成如下:

import android.support.v7.app.AppCompatActivity;

我就是這樣子修改完後,運行後就閃退,一啓動APP就閃退,控制檯“Logcat”沒有抓獲到奔潰異常,最後排查發現,還差一個東西沒有修改

四.activity_main.xml,(太容易忽視了)

<androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

 改成

<android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>

小小bug,都是粗心造成,以此警戒!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章