build.gradle文件

apply plugin: 'com.android.application'android {    compileSdkVersion 28  //版本较高,用androidx开头的合适,之前在别的项目拷贝了一个android开头的依赖,哪里的sdk设置的版本都较低    buildToolsVersion "29.0.2"//版本较高    defaultConfig {        applicationId "com.example"        minSdkVersion 19       // 应用程序支持api的下限        targetSdkVersion 28        versionCode 1        versionName "1.0"        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'        }    }}dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    //    RecyclerView 依赖库,(我出现这个问题是因为这个版本与上面sdk设置不兼容,现在的这个为兼容依赖)    implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1'    implementation 'androidx.appcompat:appcompat:1.0.2'    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'    implementation 'com.google.android.material:material:1.0.0'    implementation 'androidx.legacy:legacy-support-v4:1.0.0'    implementation 'androidx.navigation:navigation-fragment:2.0.0'    implementation 'androidx.navigation:navigation-ui:2.0.0'    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'androidx.test.ext:junit:1.1.0'    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'}

对应的xml文件xxx.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">    <RelativeLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="#ffececec">    <androidx.recyclerview.widget.RecyclerView        android:id="@+id/recycler_view"        android:layout_width="match_parent"        android:layout_height="match_parent" />    </RelativeLayout></LinearLayout>

此次情景
版本与上面sdk设置不兼容,一下几个参数对版本都做了限制

    minSdkVersion 19    //最小版本限制    targetSdkVersion 28 //targetSdkVersion保证的是api的一致性。一般minSdkVersion 

更多相关文章

  1. 实用代码3
  2. 使用Android(安卓)Studio搭建Android集成开发环境(图文教程)
  3. android editText 软键盘enter键图标的设置
  4. ubuntu 下编译android libjpeg-turbo-1.5.2
  5. Android(安卓)使用ActivityOptions实现Activity转场动画
  6. 【Android】android:padding属性设置对ImageButton无效问题
  7. android 背景图片设置
  8. Android(安卓)软键盘问题总结
  9. android通知栏Notification

随机推荐

  1. 【Android】手写优化-更为平滑的签名效果
  2. 利用Handler来修改Android的UI
  3. CyanogenMod 10 修改 Vold 使 Android(安
  4. Android中View和ViewGroup介绍
  5. 【Based Android】让你的android应用使用
  6. andriod环境的配置eclipse
  7. Android的隐私保护利器
  8. ANDROID 开机启动VNC SERVER
  9. Android手机搭建Linux服务器
  10. Android——用户登陆及用户名和密码的保