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>